From 1407c30f51fc645ea8a42543d51f0d7a17f2548e Mon Sep 17 00:00:00 2001 From: Oriol Ferrer Mesia Date: Thu, 22 Oct 2020 01:50:50 +0200 Subject: [PATCH 1/2] add crt-blurPi slang shader variants --- crt/crt-blurPi-sharp.slangp | 11 +++++ crt/crt-blurPi-soft.slangp | 7 +++ crt/shaders/crt-blurPi.slang | 84 ++++++++++++++++++++++++++++++++++++ 3 files changed, 102 insertions(+) create mode 100644 crt/crt-blurPi-sharp.slangp create mode 100644 crt/crt-blurPi-soft.slangp create mode 100644 crt/shaders/crt-blurPi.slang diff --git a/crt/crt-blurPi-sharp.slangp b/crt/crt-blurPi-sharp.slangp new file mode 100644 index 0000000..ff6c67a --- /dev/null +++ b/crt/crt-blurPi-sharp.slangp @@ -0,0 +1,11 @@ +shaders = 1 + +shader0 = shaders/crt-blurPi.slang +filter_linear0 = false +scale_type0 = viewport +scale0 = 1.0 +alias0 = "PASS0" + +parameters = "blurGain;blurRadius" +blurGain = "0.5" +blurRadius = "1.5" diff --git a/crt/crt-blurPi-soft.slangp b/crt/crt-blurPi-soft.slangp new file mode 100644 index 0000000..e1ec12b --- /dev/null +++ b/crt/crt-blurPi-soft.slangp @@ -0,0 +1,7 @@ +shaders = 1 + +shader0 = shaders/crt-blurPi.slang +filter_linear0 = true +scale_type0 = viewport +scale0 = 1.0 +alias0 = "PASS0" \ No newline at end of file diff --git a/crt/shaders/crt-blurPi.slang b/crt/shaders/crt-blurPi.slang new file mode 100644 index 0000000..8976bd8 --- /dev/null +++ b/crt/shaders/crt-blurPi.slang @@ -0,0 +1,84 @@ +#version 450 + +/* + +- crt-blurPi slang shader - + +Looks good on low res screens (640 x 480 or less), providing screen space scanlines. +Developed on and for the Raspberry Pi. + +Made by Oriol Ferrer MesiĆ  (armadillu) +http://uri.cat + +MIT license +*/ + + +layout(push_constant) uniform Push{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; + //params.... + float scanlineGain; + float rgbExtraGain; + float blurGain; + float blurRadius; +}params; + + +#pragma name crt-blurPi +#pragma parameter scanlineGain "scanlineGain" 0.30 0.0 1.0 0.05 +#pragma parameter rgbExtraGain "rgbExtraGain" 0.10 0.0 1.0 0.05 +#pragma parameter blurGain "blurGain" 0.15 0.0 1.0 0.05 +#pragma parameter blurRadius "blurRadius" 1.5 0.1 3.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; +layout(location = 1) out vec2 dot_size; + +void main(){ + gl_Position = global.MVP * Position; + vTexCoord = TexCoord; + dot_size = params.SourceSize.zw; +} + + +///////////////////////////////////////////////////////////////////////////////////////// +#pragma stage fragment +///////////////////////////////////////////////////////////////////////////////////////// + +layout(location = 0) in vec2 vTexCoord; +layout(location = 1) in vec2 dot_size; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main(){ + + float time = mod(params.FrameCount / 60.0, params.OutputSize.y); + + const vec2 off = params.blurRadius * dot_size; + float srcGain = 1.0f - 0.75f * params.blurGain; + + vec4 blurred = srcGain * (1.0f + params.rgbExtraGain) * texture(Source, vTexCoord) + + 0.25f * params.blurGain * texture(Source, vTexCoord + vec2(-off.x ,0.0f)) + + 0.25f * params.blurGain * texture(Source, vTexCoord + vec2(off.x, 0.0f)) + + 0.25f * params.blurGain * texture(Source, vTexCoord + vec2(0.0f, off.y)) + ; + + float scanLine = mod(int(vTexCoord.y * params.OutputSize.y), 2.0f); + + FragColor = mix(1.0f, scanLine * scanLine, params.scanlineGain) * blurred; + +} \ No newline at end of file From 78aad452f7dc6bd33c7e280096f09fd5f30ba6da Mon Sep 17 00:00:00 2001 From: Oriol Ferrer Mesia Date: Thu, 22 Oct 2020 02:11:17 +0200 Subject: [PATCH 2/2] rm old stale code --- crt/shaders/crt-blurPi.slang | 1 - 1 file changed, 1 deletion(-) diff --git a/crt/shaders/crt-blurPi.slang b/crt/shaders/crt-blurPi.slang index 8976bd8..c1d944b 100644 --- a/crt/shaders/crt-blurPi.slang +++ b/crt/shaders/crt-blurPi.slang @@ -66,7 +66,6 @@ layout(set = 0, binding = 2) uniform sampler2D Source; void main(){ - float time = mod(params.FrameCount / 60.0, params.OutputSize.y); const vec2 off = params.blurRadius * dot_size; float srcGain = 1.0f - 0.75f * params.blurGain;