From d81d82ef48b525c8601a76bb264b6f1a4f8eaaa1 Mon Sep 17 00:00:00 2001 From: hunterk Date: Tue, 15 Jan 2019 11:29:07 -0600 Subject: [PATCH] add crt-torridgristle shaders and preset --- crt/crt-torridgristle.slangp | 44 ++++++++++++ crt/shaders/torridgristle/Brighten.slang | 43 ++++++++++++ crt/shaders/torridgristle/Candy-Bloom.slang | 53 +++++++++++++++ .../Scanline-Interpolation.slang | 36 ++++++++++ .../torridgristle/ScanlineSimple.slang | 67 +++++++++++++++++++ .../torridgristle/sunset-gaussian-horiz.slang | 49 ++++++++++++++ .../torridgristle/sunset-gaussian-vert.slang | 49 ++++++++++++++ 7 files changed, 341 insertions(+) create mode 100644 crt/crt-torridgristle.slangp create mode 100644 crt/shaders/torridgristle/Brighten.slang create mode 100644 crt/shaders/torridgristle/Candy-Bloom.slang create mode 100644 crt/shaders/torridgristle/Scanline-Interpolation.slang create mode 100644 crt/shaders/torridgristle/ScanlineSimple.slang create mode 100644 crt/shaders/torridgristle/sunset-gaussian-horiz.slang create mode 100644 crt/shaders/torridgristle/sunset-gaussian-vert.slang diff --git a/crt/crt-torridgristle.slangp b/crt/crt-torridgristle.slangp new file mode 100644 index 0000000..44303e9 --- /dev/null +++ b/crt/crt-torridgristle.slangp @@ -0,0 +1,44 @@ +shaders = 7 + +shader0 = shaders/torridgristle/Scanline-Interpolation.slang +filter_linear0 = true +scale_type0 = source + +shader1 = shaders/torridgristle/ScanlineSimple.slang +filter_linear1 = true +scale_type1 = source +scale1 = 3.0 + +shader2 = ../reshade/shaders/blendoverlay/blendoverlay.slang +filter_linear2 = true +scale_type2 = viewport + +shader3 = shaders/torridgristle/Brighten.slang +filter_linear3 = true +alias3 = candy_ref + +shader4 = shaders/torridgristle/sunset-gaussian-vert.slang +filter_linear4 = true +scale_type4 = source + +shader5 = shaders/torridgristle/sunset-gaussian-horiz.slang +filter_linear5 = true +scale_type5 = source + +shader6 = shaders/torridgristle/Candy-Bloom.slang +filter_linear6 = true + +textures = "overlay" +overlay = ../reshade/shaders/blendoverlay/shadowmask-4x4.png +filter_overlay = linear + +parameters = "ScanlineSize;YIQAmount;BrightenLevel;BrightenAmount;GlowLevel;GlowTightness;LUTHeight;LUTWidth;OverlayMix" +ScanlineSize = 3.0; +YIQAmount = 0.35; +BrightenLevel = 2.0; +BrightenAmount = 0.1; +GlowLevel = 1.0; +GlowTightness = 0.8; +LUTWidth = 4.0 +LUTHeight = 4.0 +OverlayMix = 0.5 \ No newline at end of file diff --git a/crt/shaders/torridgristle/Brighten.slang b/crt/shaders/torridgristle/Brighten.slang new file mode 100644 index 0000000..7c25296 --- /dev/null +++ b/crt/shaders/torridgristle/Brighten.slang @@ -0,0 +1,43 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; + float BrightenLevel; + float BrightenAmount; +} params; + +#pragma parameter BrightenLevel "Brighten Level" 2.0 1.0 10.0 1.0 +#pragma parameter BrightenAmount "Brighten Amount" 0.1 0.0 1.0 0.1 + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +#pragma stage vertex +layout(location = 0) in vec4 Position; +layout(location = 1) in vec2 TexCoord; +layout(location = 0) out vec2 vTexCoord; + +void main() +{ + gl_Position = global.MVP * Position; + vTexCoord = TexCoord; +} + +#pragma stage fragment +layout(location = 0) in vec2 vTexCoord; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 Picture = texture(Source, vTexCoord).xyz; + Picture = clamp(Picture,0.0,1.0); + + FragColor = vec4(mix(Picture,1.0-pow(1.0-Picture,vec3(params.BrightenLevel)),params.BrightenAmount),1.0); +} \ No newline at end of file diff --git a/crt/shaders/torridgristle/Candy-Bloom.slang b/crt/shaders/torridgristle/Candy-Bloom.slang new file mode 100644 index 0000000..8786857 --- /dev/null +++ b/crt/shaders/torridgristle/Candy-Bloom.slang @@ -0,0 +1,53 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; + float GlowLevel; + float GlowTightness; +} params; + +#pragma parameter GlowLevel "Glow Level" 1.0 0.0 1.0 0.1 +#pragma parameter GlowTightness "Glow Tightness" 0.5 0.0 1.0 0.1 + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +#pragma stage vertex +layout(location = 0) in vec4 Position; +layout(location = 1) in vec2 TexCoord; +layout(location = 0) out vec2 vTexCoord; + +void main() +{ + gl_Position = global.MVP * Position; + vTexCoord = TexCoord; +} + +#pragma stage fragment +layout(location = 0) in vec2 vTexCoord; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; +layout(set = 0, binding = 3) uniform sampler2D candy_ref; + +void main() +{ + vec3 Picture = texture(Source, vTexCoord).xyz; + + float MaxRGB = max(Picture.x, max(Picture.y, Picture.z)); + float MinRGB = min(Picture.x, min(Picture.y, Picture.z)); + + float YIQLuminance = ((0.299*Picture.x) + (0.587*Picture.y) + (0.114*Picture.z)); + + + Picture /= MaxRGB; + Picture = clamp(Picture,0.0,1.0); + + + FragColor = vec4(mix(texture(candy_ref, vTexCoord).xyz, Picture, mix(1.-pow(1.-YIQLuminance,2.0),YIQLuminance*YIQLuminance,params.GlowTightness)*params.GlowLevel),1.0); +} \ No newline at end of file diff --git a/crt/shaders/torridgristle/Scanline-Interpolation.slang b/crt/shaders/torridgristle/Scanline-Interpolation.slang new file mode 100644 index 0000000..c80cfa7 --- /dev/null +++ b/crt/shaders/torridgristle/Scanline-Interpolation.slang @@ -0,0 +1,36 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +#pragma stage vertex +layout(location = 0) in vec4 Position; +layout(location = 1) in vec2 TexCoord; +layout(location = 0) out vec2 vTexCoord; + +void main() +{ + gl_Position = global.MVP * Position; + vTexCoord = TexCoord; +} + +#pragma stage fragment +layout(location = 0) in vec2 vTexCoord; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec2 texCoordHard = vec2(vTexCoord.x,(floor(vTexCoord.y*params.SourceSize.y)+0.5)/params.SourceSize.y); + FragColor = vec4(texture(Source, texCoordHard).rgb, 1.0); +} \ No newline at end of file diff --git a/crt/shaders/torridgristle/ScanlineSimple.slang b/crt/shaders/torridgristle/ScanlineSimple.slang new file mode 100644 index 0000000..7981826 --- /dev/null +++ b/crt/shaders/torridgristle/ScanlineSimple.slang @@ -0,0 +1,67 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; + float ScanlineSize; + float YIQAmount; +} params; + +#pragma parameter ScanlineSize "Scanline Size" 3.0 2.0 32.0 1.0 +#pragma parameter YIQAmount "YIQ Amount" 1.0 0.0 1.0 0.05 + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +#pragma stage vertex +layout(location = 0) in vec4 Position; +layout(location = 1) in vec2 TexCoord; +layout(location = 0) out vec2 vTexCoord; + +void main() +{ + gl_Position = global.MVP * Position; + vTexCoord = TexCoord; +} + +#pragma stage fragment +layout(location = 0) in vec2 vTexCoord; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +#define Pi 3.1415926536 +const mat3 RGB_to_YIQ = mat3( 0.299 , 0.595716 , 0.211456 , 0.587 , -0.274453 , -0.522591 , 0.114 , -0.321263 , 0.311135 ); +const mat3 YIQ_to_RGB = mat3( 1.0 , 1.0 , 1.0 , 0.9563 , -0.2721 , -1.1070 , 0.6210 , -0.6474 , 1.7046 ); + +void main() +{ + vec3 Picture = texture(Source,vTexCoord).xyz; + + float HSBrightness = max(max(Picture.x,Picture.y),max(Picture.y,Picture.z)); + float YIQLuminance = ((0.299*Picture.x) + (0.587*Picture.y) + (0.114*Picture.z)); + + float HSBYIQHybrid = mix(HSBrightness,YIQLuminance,HSBrightness); + + float Scanline = mod(vTexCoord.y*params.OutputSize.y,params.ScanlineSize)/params.ScanlineSize; + Scanline = 1.-abs(Scanline-0.5)*2.; + Scanline = 1.-pow(1.-Scanline,2.0); + + Scanline = clamp(sqrt(Scanline)-(1-HSBYIQHybrid),0.0,1.0); + Scanline /= HSBYIQHybrid; + + + + vec3 YIQApplication = Picture * RGB_to_YIQ; + YIQApplication.x *= Scanline; + YIQApplication *= YIQ_to_RGB; + + FragColor = vec4(mix(Picture*Scanline,YIQApplication*mix(Scanline,1.0,0.75),params.YIQAmount),1.0); + //FragColor = vec4(Picture,1.0); + //FragColor = vec4(Scanline); + +} \ No newline at end of file diff --git a/crt/shaders/torridgristle/sunset-gaussian-horiz.slang b/crt/shaders/torridgristle/sunset-gaussian-horiz.slang new file mode 100644 index 0000000..ee56aca --- /dev/null +++ b/crt/shaders/torridgristle/sunset-gaussian-horiz.slang @@ -0,0 +1,49 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +#pragma stage vertex +layout(location = 0) in vec4 Position; +layout(location = 1) in vec2 TexCoord; +layout(location = 0) out vec2 vTexCoord; +layout(location = 1) out vec2 blurCoordinates[5]; + +void main() +{ + gl_Position = global.MVP * Position; + vTexCoord = TexCoord; + + blurCoordinates[0] = vTexCoord.xy; + blurCoordinates[1] = vTexCoord.xy + params.OutputSize.zw * vec2(1.407333,0.0); + blurCoordinates[2] = vTexCoord.xy - params.OutputSize.zw * vec2(1.407333,0.0); + blurCoordinates[3] = vTexCoord.xy + params.OutputSize.zw * vec2(3.294215,0.0); + blurCoordinates[4] = vTexCoord.xy - params.OutputSize.zw * vec2(3.294215,0.0); +} + +#pragma stage fragment +layout(location = 0) in vec2 vTexCoord; +layout(location = 1) in vec2 blurCoordinates[5]; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec4 sum = vec4(0.0); + sum += texture(Source, blurCoordinates[0]) * 0.204164; + sum += texture(Source, blurCoordinates[1]) * 0.304005; + sum += texture(Source, blurCoordinates[2]) * 0.304005; + sum += texture(Source, blurCoordinates[3]) * 0.093913; + sum += texture(Source, blurCoordinates[4]) * 0.093913; + FragColor = sum; +} \ No newline at end of file diff --git a/crt/shaders/torridgristle/sunset-gaussian-vert.slang b/crt/shaders/torridgristle/sunset-gaussian-vert.slang new file mode 100644 index 0000000..582fe64 --- /dev/null +++ b/crt/shaders/torridgristle/sunset-gaussian-vert.slang @@ -0,0 +1,49 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +#pragma stage vertex +layout(location = 0) in vec4 Position; +layout(location = 1) in vec2 TexCoord; +layout(location = 0) out vec2 vTexCoord; +layout(location = 1) out vec2 blurCoordinates[5]; + +void main() +{ + gl_Position = global.MVP * Position; + vTexCoord = TexCoord; + + blurCoordinates[0] = vTexCoord.xy; + blurCoordinates[1] = vTexCoord.xy + params.OutputSize.zw * vec2(0.,1.407333); + blurCoordinates[2] = vTexCoord.xy - params.OutputSize.zw * vec2(0.,1.407333); + blurCoordinates[3] = vTexCoord.xy + params.OutputSize.zw * vec2(0.,3.294215); + blurCoordinates[4] = vTexCoord.xy - params.OutputSize.zw * vec2(0.,3.294215); +} + +#pragma stage fragment +layout(location = 0) in vec2 vTexCoord; +layout(location = 1) in vec2 blurCoordinates[5]; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec4 sum = vec4(0.0); + sum += texture(Source, blurCoordinates[0]) * 0.204164; + sum += texture(Source, blurCoordinates[1]) * 0.304005; + sum += texture(Source, blurCoordinates[2]) * 0.304005; + sum += texture(Source, blurCoordinates[3]) * 0.093913; + sum += texture(Source, blurCoordinates[4]) * 0.093913; + FragColor = sum; +} \ No newline at end of file