diff --git a/crt/crt-yo6-KV-M1420B-sharp.slangp b/crt/crt-yo6-KV-M1420B-sharp.slangp new file mode 100644 index 0000000..31b8ac0 --- /dev/null +++ b/crt/crt-yo6-KV-M1420B-sharp.slangp @@ -0,0 +1,27 @@ +shaders = 3 + +shader0 = "shaders/crt-yo6/crt-yo6-native-resolution.slang" +filter_linear0 = true +wrap_mode0 = "clamp_to_edge" +scale_type0 = "absolute" +scale_x0 = 439 +scale_y0 = 233 + +shader1 = "shaders/crt-yo6/crt-yo6-warp.slang" +filter_linear1 = true +wrap_mode1 = "clamp_to_edge" +scale_type1 = "absolute" +scale_x1 = 1684 +scale_y1 = 1329 + +shader2 = "../windowed/shaders/jinc2.slang" +filter_linear2 = false + +textures = TEX_CRT +TEX_CRT = "shaders/crt-yo6/KV-M1420B.png" +TEX_CRT_linear = false + +parameters = "JINC2_WINDOW_SINC;JINC2_SINC;JINC2_AR_STRENGTH" +JINC2_WINDOW_SINC = 0.44 +JINC2_SINC = 0.82 +JINC2_AR_STRENGTH = 0.5 diff --git a/crt/crt-yo6-KV-M1420B.slangp b/crt/crt-yo6-KV-M1420B.slangp new file mode 100644 index 0000000..d0685b6 --- /dev/null +++ b/crt/crt-yo6-KV-M1420B.slangp @@ -0,0 +1,27 @@ +shaders = 3 + +shader0 = "shaders/crt-yo6/crt-yo6-native-resolution.slang" +filter_linear0 = true +wrap_mode0 = "clamp_to_edge" +scale_type0 = "absolute" +scale_x0 = 439 +scale_y0 = 233 + +shader1 = "shaders/crt-yo6/crt-yo6-warp.slang" +filter_linear1 = true +wrap_mode1 = "clamp_to_edge" +scale_type1 = "absolute" +scale_x1 = 1684 +scale_y1 = 1329 + +shader2 = "../windowed/shaders/jinc2.slang" +filter_linear2 = false + +textures = TEX_CRT +TEX_CRT = "shaders/crt-yo6/KV-M1420B.png" +TEX_CRT_linear = false + +parameters = "JINC2_WINDOW_SINC;JINC2_SINC;JINC2_AR_STRENGTH" +JINC2_WINDOW_SINC = 0.44 +JINC2_SINC = 0.40 +JINC2_AR_STRENGTH = 0.0 diff --git a/crt/shaders/crt-yo6/KV-M1420B.png b/crt/shaders/crt-yo6/KV-M1420B.png new file mode 100644 index 0000000..7322c42 Binary files /dev/null and b/crt/shaders/crt-yo6/KV-M1420B.png differ diff --git a/crt/shaders/crt-yo6/crt-yo6-native-resolution.slang b/crt/shaders/crt-yo6/crt-yo6-native-resolution.slang new file mode 100644 index 0000000..a127cc1 --- /dev/null +++ b/crt/shaders/crt-yo6/crt-yo6-native-resolution.slang @@ -0,0 +1,42 @@ +#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 float vU; +layout(location = 1) out float vY; + +void main() +{ + gl_Position = global.MVP * Position; + vU = TexCoord.x; + vY = (TexCoord.y * params.OutputSize.y) - + round((params.OutputSize.y - params.SourceSize.y) / 2.0); +} + +#pragma stage fragment +layout(location = 0) in float vU; +layout(location = 1) in float vY; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + float clip0 = (sign(vY) + 1.0) / 2.0; + float clipH = (sign(params.SourceSize.y - vY) + 1.0) / 2.0; + vec3 col = texture(Source, vec2(vU, vY / params.SourceSize.y)).rgb; + FragColor = vec4(clip0 * clipH * col, 1.0); +} diff --git a/crt/shaders/crt-yo6/crt-yo6-warp.slang b/crt/shaders/crt-yo6/crt-yo6-warp.slang new file mode 100644 index 0000000..322c994 --- /dev/null +++ b/crt/shaders/crt-yo6/crt-yo6-warp.slang @@ -0,0 +1,43 @@ +#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; +layout(set = 0, binding = 3) uniform sampler2D TEX_CRT; + + +void main() +{ + const vec3 packed = texture(TEX_CRT, vTexCoord).rgb; + + const vec2 dudv = ((packed.rg * 255.0) / 16.0) - 7.0; + const vec2 uv0 = vTexCoord * params.SourceSize.xy; + const vec2 uv = (uv0 + dudv) / params.SourceSize.xy; + + FragColor = vec4(packed.b * texture(Source, uv).rgb, 1.0); +}