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 all 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
6 changes: 5 additions & 1 deletion .github/actions/spell-check/dictionary/apis.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ cmdletbinding
COLORPROPERTY
CXICON
CYICON
D2DERR_SHADER_COMPILE_FAILED
DERR
environstrings
EXPCMDFLAGS
EXPCMDSTATE
frac
fullkbd
futex
GETDESKWALLPAPER
Expand All @@ -34,7 +37,6 @@ IObject
IStorage
ITab
ITaskbar
llabs
LCID
llabs
localtime
Expand Down Expand Up @@ -64,6 +66,7 @@ semver
serializer
shobjidl
SIZENS
smoothstep
GETDESKWALLPAPER
snprintf
spsc
Expand All @@ -83,6 +86,7 @@ UPDATEINIFILE
userenv
wcsstr
wcstoui
wpc
wsregex
XDocument
XElement
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 @@ -1591,6 +1596,7 @@ OACR
oauth
objbase
ocf
ocolor
odl
oem
oemcp
Expand Down Expand Up @@ -1789,6 +1795,7 @@ pragma
prc
prealigned
prebuilt
precendence
precomp
prect
prefast
Expand Down Expand Up @@ -1834,6 +1841,7 @@ pshn
PSHNOTIFY
PSHORT
pshpack
psin
PSINGLE
psl
psldl
Expand Down Expand Up @@ -1882,10 +1890,12 @@ QWER
qzmp
RAII
RALT
rasterbar
rasterfont
rasterization
rawinput
RAWPATH
raytracers
razzlerc
rbar
rbegin
Expand Down Expand Up @@ -1956,9 +1966,11 @@ RESETCONTENT
resheader
resizable
resmimetype
reso
restrictedcapabilities
resw
resx
RETROII
retval
rfa
rfc
Expand Down Expand Up @@ -2029,11 +2041,14 @@ SBCSDBCS
sbi
sbiex
sbold
sbri
scanbri
scancode
scanline
schemename
SCL
scm
scol
scprintf
SCRBUF
SCRBUFSIZE
Expand Down Expand Up @@ -2167,6 +2182,9 @@ SOURCESDIRECTORY
SPACEBAR
spammy
spand
spe
sph
spherefunctions
splashscreen
sprintf
sqlproj
Expand Down Expand Up @@ -2296,6 +2314,7 @@ tellp
telnet
telnetd
templated
teraflop
terminalcore
TERMINALSCROLLING
terminfo
Expand Down Expand Up @@ -2544,6 +2563,7 @@ vga
vgaoem
viewkind
viewports
Viginetting
Virt
VIRTTERM
Virtualizing
Expand Down Expand Up @@ -2760,6 +2780,7 @@ wwaproj
WWith
wx
wxh
wz
xa
xact
xamarin
Expand Down Expand Up @@ -2809,7 +2830,10 @@ xutr
xvalue
XVIRTUALSCREEN
XWalk
XWV
xy
xyw
Xzn
yact
YAML
YCast
Expand All @@ -2825,6 +2849,7 @@ YVIRTUALSCREEN
Yw
YWalk
yx
yzx
Zc
ZCmd
ZCtrl
Expand Down
6 changes: 5 additions & 1 deletion doc/cascadia/profiles.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
"toggleFocusMode",
"toggleFullscreen",
"togglePaneZoom",
"toggleRetroEffect",
"toggleShaderEffects",
"wt",
"unbound"
],
Expand Down Expand Up @@ -936,6 +936,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.pixelShaderPath": {
"description": "Use to set a path to a pixel shader to use with the Terminal. Overrides `experimental.retroTerminalEffect`. This is an experimental feature, and its continued existence is not guaranteed.",
"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;
}
Loading