From aaf83724d30943a146567c0493a33ef9dfbdb36c Mon Sep 17 00:00:00 2001 From: metallic77 <43163462+metallic77@users.noreply.github.com> Date: Sat, 29 Apr 2023 06:20:58 +0300 Subject: [PATCH] add fake-crt-geom-potato (#409) * add fake-crt-geom-potato * add fake-crt-geom-potato * Update fake-crt-geom.slang Add cheap Color Temperature Control --- crt/fake-crt-geom-potato.slangp | 5 ++ crt/shaders/fake-crt-geom-potato.slang | 83 ++++++++++++++++++++++++++ crt/shaders/fake-crt-geom.slang | 8 ++- 3 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 crt/fake-crt-geom-potato.slangp create mode 100644 crt/shaders/fake-crt-geom-potato.slang diff --git a/crt/fake-crt-geom-potato.slangp b/crt/fake-crt-geom-potato.slangp new file mode 100644 index 0000000..d0077c8 --- /dev/null +++ b/crt/fake-crt-geom-potato.slangp @@ -0,0 +1,5 @@ +shaders = 1 + +shader0 = shaders/fake-crt-geom-potato.slang +filter_linear0 = true +scale_type0 = viewport diff --git a/crt/shaders/fake-crt-geom-potato.slang b/crt/shaders/fake-crt-geom-potato.slang new file mode 100644 index 0000000..83ce083 --- /dev/null +++ b/crt/shaders/fake-crt-geom-potato.slang @@ -0,0 +1,83 @@ +#version 450 + +// Simple scanlines with curvature and mask effects lifted from crt-geom +// original by hunterk, edited by DariusG + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; + float SCANLINE; + float cgwg; + float boost; +} params; + +// Parameter lines go here: + +#pragma parameter boost "Bright boost " 1.00 1.00 2.00 0.02 +#define boost params.boost + +#pragma parameter SCANLINE "Scanline Intensity" 0.30 0.0 1.0 0.05 +#define SCANLINE params.SCANLINE + +#pragma parameter cgwg "CGWG mask brightness " 0.7 0.0 1.0 0.1 +#define cgwg params.cgwg + +#define pi 3.141592654 + +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 float omega; + +void main() +{ + gl_Position = global.MVP * Position; + vTexCoord = TexCoord * 1.0001; + omega = pi * params.SourceSize.y * 2.0; +} + +#pragma stage fragment +layout(location = 0) in vec2 vTexCoord; +layout(location = 1) in float omega; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 1) uniform sampler2D Source; + + +/////////////////////////////////////////////////////////////////////////////////////////////// + +// CGWG mask calculation + + vec3 Mask(float pos) + { + + float mf = fract(pos * 0.5); + + if (mf <0.5) return vec3(1.0,cgwg,1.0); + else return vec3(cgwg,1.0,cgwg); + + } + +void main() +{ + vec2 pos = vTexCoord.xy; + vec3 res = texture(Source, pos).rgb; + + if (params.OriginalSize.y < 400.0) + res = res * (1.0 + SCANLINE * sin(pos.y * omega)); + else res; + +// apply the mask + res *= Mask(pos.x*params.OutputSize.x * 1.0001); + res *= boost; + + FragColor = vec4(res,1.0); +} diff --git a/crt/shaders/fake-crt-geom.slang b/crt/shaders/fake-crt-geom.slang index 2f1c3bc..b0e2aef 100644 --- a/crt/shaders/fake-crt-geom.slang +++ b/crt/shaders/fake-crt-geom.slang @@ -16,7 +16,9 @@ layout(push_constant) uniform Push float cgwg; float boost; float SHARPNESS; - float SPEEDUP; + float SPEEDUP; + float WP; + } params; // Parameter lines go here: @@ -41,6 +43,9 @@ layout(push_constant) uniform Push #pragma parameter boost "Bright boost " 1.00 1.00 2.00 0.02 #define boost params.boost +#pragma parameter WP "Color Temperature" 0.0 -0.25 0.25 0.01 +#define WP params.WP + #pragma parameter SPEEDUP "Speed-up. Warp,Gamma,Corner disabled" 0.0 0.0 1.0 1.0 #define SPEEDUP params.SPEEDUP @@ -157,6 +162,7 @@ void main() vec3 color = scanline(pos.y, res); if (SPEEDUP == 0.0) color = pow( color, out_gamma); else color; if (SPEEDUP == 0.0 ) color = color*corner(tc); + color.rgb *= vec3(1.0+WP,1.0,1.0-WP); FragColor = vec4(color,1.0) ;