Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement user-specified pixel shaders, redux #8565

Merged
13 commits merged into from
Dec 15, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/actions/spell-check/dictionary/apis.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ CYICON
environstrings
EXPCMDFLAGS
EXPCMDSTATE
frac
fullkbd
futex
GETDESKWALLPAPER
Expand All @@ -33,7 +34,6 @@ IMap
IObject
IStorage
ITaskbar
llabs
LCID
llabs
localtime
Expand Down Expand Up @@ -63,6 +63,7 @@ semver
serializer
shobjidl
SIZENS
smoothstep
spsc
sregex
STDCPP
Expand Down
9 changes: 8 additions & 1 deletion .github/actions/spell-check/dictionary/names.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,20 @@ ekg
ethanschoonover
Firefox
Gatta
glsl
Grie
Griese
Hernan
Howett
Illhardt
iquilezles
jantari
jerrysh
Kaiyu
kimwalisch
KMehrain
KODELIFE
Kodelife
Kourosh
kowalczyk
leonmsft
Expand All @@ -30,6 +34,7 @@ lukesampson
Manandhar
mbadolato
Mehrain
menger
mgravell
michaelniksa
michkap
Expand All @@ -43,6 +48,7 @@ nvaccess
nvda
oising
oldnewthing
opengl
osgwiki
paulcam
pauldotknopf
Expand All @@ -51,6 +57,7 @@ Pham
Rincewind
rprichard
Schoonover
shadertoy
Somuah
sonph
sonpham
Expand All @@ -60,8 +67,8 @@ Wirt
Wojciech
zadjii
Zamor
Zamora
zamora
Zamora
Zoey
zorio
Zverovich
27 changes: 26 additions & 1 deletion .github/actions/spell-check/expect/expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ ADDREF
addressof
ADDSTRING
ADDTOOL
AEnd
aef
AEnd
AFew
AFill
AFX
Expand Down Expand Up @@ -628,6 +628,7 @@ doskey
dotnet
doubleclick
downlevel
DOWNSCALE
dpg
dpi
DPIAPI
Expand Down Expand Up @@ -832,6 +833,7 @@ fuzzwrapper
fwdecl
fwe
fwlink
GAUSSIAN
gb
gci
gcx
Expand Down Expand Up @@ -909,6 +911,7 @@ Goldmine
gonce
Google
goutput
GPUs
Gravell's
grayscale
GREENSCROLL
Expand Down Expand Up @@ -1109,6 +1112,7 @@ INTERCEPTCOPYPASTE
INTERNALNAME
interop
interoperability
intersectors
inthread
intptr
intsafe
Expand Down Expand Up @@ -1207,6 +1211,7 @@ KJ
KLF
KLMNOPQRST
KLMNOPQRSTQQQQQ
Kode
KU
KVM
KX
Expand Down Expand Up @@ -1588,6 +1593,7 @@ OACR
oauth
objbase
ocf
ocolor
odl
oem
oemcp
Expand Down Expand Up @@ -1786,6 +1792,7 @@ pragma
prc
prealigned
prebuilt
precendence
precomp
prect
prefast
Expand Down Expand Up @@ -1831,6 +1838,7 @@ pshn
PSHNOTIFY
PSHORT
pshpack
psin
PSINGLE
psl
psldl
Expand Down Expand Up @@ -1879,10 +1887,12 @@ QWER
qzmp
RAII
RALT
rasterbar
rasterfont
rasterization
rawinput
RAWPATH
raytracers
razzlerc
rbar
rbegin
Expand Down Expand Up @@ -1953,9 +1963,11 @@ RESETCONTENT
resheader
resizable
resmimetype
reso
restrictedcapabilities
resw
resx
RETROII
retval
rfa
rfc
Expand Down Expand Up @@ -2026,11 +2038,14 @@ SBCSDBCS
sbi
sbiex
sbold
sbri
scanbri
scancode
scanline
schemename
SCL
scm
scol
scprintf
SCRBUF
SCRBUFSIZE
Expand Down Expand Up @@ -2164,6 +2179,9 @@ SOURCESDIRECTORY
SPACEBAR
spammy
spand
spe
sph
spherefunctions
splashscreen
sprintf
sqlproj
Expand Down Expand Up @@ -2293,6 +2311,7 @@ tellp
telnet
telnetd
templated
teraflop
terminalcore
TERMINALSCROLLING
terminfo
Expand Down Expand Up @@ -2541,6 +2560,7 @@ vga
vgaoem
viewkind
viewports
Viginetting
Virt
VIRTTERM
Virtualizing
Expand Down Expand Up @@ -2757,6 +2777,7 @@ wwaproj
WWith
wx
wxh
wz
xa
xact
xamarin
Expand Down Expand Up @@ -2806,7 +2827,10 @@ xutr
xvalue
XVIRTUALSCREEN
XWalk
XWV
xy
xyw
Xzn
yact
YAML
YCast
Expand All @@ -2822,6 +2846,7 @@ YVIRTUALSCREEN
Yw
YWalk
yx
yzx
Zc
ZCmd
ZCtrl
Expand Down
4 changes: 4 additions & 0 deletions doc/cascadia/profiles.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -931,6 +931,10 @@
"description": "When set to true, enable retro terminal effects. This is an experimental feature, and its continued existence is not guaranteed.",
"type": "boolean"
},
"experimental.pixelShaderEffect": {
"description": "If set to a file name or preset, compiles the pixel shader effect and applies it the terminal view. Currently 2 presets are supported `RETRO` and `RETROII`. This is an experimental feature, and its continued existence is not guaranteed.",
zadjii-msft marked this conversation as resolved.
Show resolved Hide resolved
"type": "string"
},
"fontFace": {
"default": "Cascadia Mono",
"description": "Name of the font face used in the profile.",
Expand Down
18 changes: 18 additions & 0 deletions samples/PixelShaders/Broken.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Broken, can be used for explorative testing of pixel shader error handling
Texture2D shaderTexture;
SamplerState samplerState;

cbuffer PixelShaderSettings {
float Time;
float Scale;
float2 Resolution;
float4 Background;
};

float4 main(float4 pos : SV_POSITION, float2 tex : TEXCOORD) : SV_TARGET
{
// OOPS; vec4 is not a hlsl but a glsl datatype!
vec4 color = shaderTexture.Sample(samplerState, tex);

return color;
}
18 changes: 18 additions & 0 deletions samples/PixelShaders/Error.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Shader used to indicate something went wrong during shader loading
Texture2D shaderTexture;
SamplerState samplerState;

cbuffer PixelShaderSettings {
float Time;
float Scale;
float2 Resolution;
float4 Background;
};

float4 main(float4 pos : SV_POSITION, float2 tex : TEXCOORD) : SV_TARGET
{
float4 color = shaderTexture.Sample(samplerState, tex);
float bars = 0.5+0.5*sin(tex.y*100);
color.x += pow(bars, 20.0);
return color;
}
32 changes: 32 additions & 0 deletions samples/PixelShaders/Grayscale.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// A minimal pixel shader that inverts the colors

// The terminal graphics as a texture
Texture2D shaderTexture;
SamplerState samplerState;

// Terminal settings such as the resolution of the texture
cbuffer PixelShaderSettings {
// Time since pixel shader was enabled
float Time;
// UI Scale
float Scale;
// Resolution of the shaderTexture
float2 Resolution;
// Background color as rgba
float4 Background;
};

// A pixel shader is a program that given a texture coordinate (tex) produces a color
// Just ignore the pos parameter
float4 main(float4 pos : SV_POSITION, float2 tex : TEXCOORD) : SV_TARGET
{
// Read the color value at the current texture coordinate (tex)
// float4 is tuple of 4 floats, rgba
float4 color = shaderTexture.Sample(samplerState, tex);
float avg = (color.x + color.y + color.z) / 3.0;
// Inverts the rgb values (xyz) but don't touch the alpha (w)
color.xyz = avg;

// Return the final color
return color;
}
32 changes: 32 additions & 0 deletions samples/PixelShaders/Invert.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// A minimal pixel shader that inverts the colors

// The terminal graphics as a texture
Texture2D shaderTexture;
SamplerState samplerState;

// Terminal settings such as the resolution of the texture
cbuffer PixelShaderSettings {
// Time since pixel shader was enabled
float Time;
// UI Scale
float Scale;
// Resolution of the shaderTexture
float2 Resolution;
// Background color as rgba
float4 Background;
};

// A pixel shader is a program that given a texture coordinate (tex) produces a color
// Just ignore the pos parameter
float4 main(float4 pos : SV_POSITION, float2 tex : TEXCOORD) : SV_TARGET
{
// Read the color value at the current texture coordinate (tex)
// float4 is tuple of 4 floats, rgba
float4 color = shaderTexture.Sample(samplerState, tex);

// Inverts the rgb values (xyz) but don't touch the alpha (w)
color.xyz = 1.0 - color.xyz;

// Return the final color
return color;
}
17 changes: 17 additions & 0 deletions samples/PixelShaders/Nop.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Does nothing, serves as an example of a minimal pixel shader
Texture2D shaderTexture;
SamplerState samplerState;

cbuffer PixelShaderSettings {
float Time;
float Scale;
float2 Resolution;
float4 Background;
};

float4 main(float4 pos : SV_POSITION, float2 tex : TEXCOORD) : SV_TARGET
{
float4 color = shaderTexture.Sample(samplerState, tex);

return color;
}
Loading