diff --git a/hdr/crt-sony-megatron-aeg-CTV-4800-VT-hdr.slangp b/hdr/crt-sony-megatron-aeg-CTV-4800-VT-hdr.slangp index 27adac0..10a87cc 100644 --- a/hdr/crt-sony-megatron-aeg-CTV-4800-VT-hdr.slangp +++ b/hdr/crt-sony-megatron-aeg-CTV-4800-VT-hdr.slangp @@ -37,12 +37,12 @@ mipmap_input4 = "false" alias4 = "" float_framebuffer4 = "false" srgb_framebuffer4 = "false" -scale_type4 = viewport hcrt_hdr = "1.000000" hcrt_crt_screen_type = "2.000000" hcrt_crt_resolution = "0.000000" hcrt_expand_gamut = "0.000000" +hcrt_saturation = "0.450000" hcrt_red_vertical_convergence = "0.000000" hcrt_green_vertical_convergence = "0.000000" diff --git a/hdr/crt-sony-megatron-default-hdr-NTSC.slangp b/hdr/crt-sony-megatron-default-hdr-NTSC.slangp new file mode 100644 index 0000000..4c2b2a0 --- /dev/null +++ b/hdr/crt-sony-megatron-default-hdr-NTSC.slangp @@ -0,0 +1,121 @@ +shaders = "9" + +shader0 = "../crt/shaders/guest/advanced/stock.slang" +filter_linear0 = "false" +wrap_mode0 = "clamp_to_border" +mipmap_input0 = "false" +alias0 = "PrePass0" +float_framebuffer0 = "false" +srgb_framebuffer0 = "false" +scale_type_x0 = "source" +scale_x0 = "1.000000" +scale_type_y0 = "source" +scale_y0 = "1.000000" + +shader1 = "../crt/shaders/guest/advanced/ntsc/ntsc-pass1.slang" +filter_linear1 = "false" +wrap_mode1 = "clamp_to_border" +mipmap_input1 = "false" +alias1 = "NPass1" +float_framebuffer1 = "true" +srgb_framebuffer1 = "false" +scale_type_x1 = "source" +scale_x1 = "4.000000" +scale_type_y1 = "source" +scale_y1 = "1.000000" + +shader2 = "../crt/shaders/guest/advanced/ntsc/ntsc-pass2.slang" +filter_linear2 = "true" +wrap_mode2 = "clamp_to_border" +mipmap_input2 = "false" +alias2 = "" +float_framebuffer2 = "true" +srgb_framebuffer2 = "false" +scale_type_x2 = "source" +scale_x2 = "0.500000" +scale_type_y2 = "source" +scale_y2 = "1.000000" + +shader3 = "../crt/shaders/guest/advanced/ntsc/ntsc-pass3.slang" +filter_linear3 = "true" +wrap_mode3 = "clamp_to_border" +mipmap_input3 = "false" +alias3 = "" +float_framebuffer3 = "false" +srgb_framebuffer3 = "false" +scale_type_x3 = "source" +scale_x3 = "1.000000" +scale_type_y3 = "source" +scale_y3 = "1.000000" + +shader4 = "../crt/shaders/guest/advanced/custom-fast-sharpen.slang" +filter_linear4 = "true" +wrap_mode4 = "clamp_to_border" +mipmap_input4 = "false" +alias4 = "NtscPass" +float_framebuffer4 = "false" +srgb_framebuffer4 = "false" +scale_type_x4 = "source" +scale_x4 = "1.000000" +scale_type_y4 = "source" +scale_y4 = "1.000000" + +shader5 = "shaders/crt-guest-advanced-ntsc-pass1a.slang" +filter_linear5 = "true" +wrap_mode5 = "clamp_to_border" +mipmap_input5 = "false" +alias5 = "Pass1" +float_framebuffer5 = "false" +srgb_framebuffer5 = "false" +scale_type_x5 = "viewport" +scale_x5 = "1.000000" +scale_type_y5 = "source" +scale_y5 = "1.000000" + +shader6 = "shaders/crt-sony-megatron-source-pass.slang" +filter_linear6 = "false" +scale_type6 = "source" +scale6 = "1.0" +wrap_mode6 = "clamp_to_border" +mipmap_input6 = "false" +alias6 = "SourceSDR" + +shader7 = "shaders/crt-sony-megatron-hdr-pass.slang" +filter_linear7 = "false" +scale_type7 = "source" +scale7 = "1.0" +wrap_mode7 = "clamp_to_border" +mipmap_input7 = "false" +alias7 = "SourceHDR" + +shader8 = "shaders/crt-sony-megatron.slang" +filter_linear8 = "false" +wrap_mode8 = "clamp_to_border" +mipmap_input8 = "false" +alias8 = "" +float_framebuffer8 = "false" +srgb_framebuffer8 = "false" + +hcrt_crt_screen_type = "0.000000" +hcrt_colour_system = "3.000000" +hcrt_contrast = "0.000000" +hcrt_brightness = "0.000000" +hcrt_saturation = "0.450000" +hcrt_gamma_in = "2.220000" +hcrt_expand_gamut = "1.000000" +hcrt_red_scanline_min = "0.8900000" +hcrt_red_scanline_max = "1.000000" +hcrt_red_scanline_attack = "0.300000" +hcrt_green_scanline_min = "0.600000" +hcrt_green_scanline_max = "0.800000" +hcrt_green_scanline_attack = "0.300000" +hcrt_blue_scanline_min = "0.600000" +hcrt_blue_scanline_max = "0.800000" +hcrt_blue_scanline_attack = "0.300000" +hcrt_red_beam_sharpness = "1.300000" +hcrt_red_beam_attack = "1.000000" +hcrt_green_beam_sharpness = "1.300000" +hcrt_green_beam_attack = "1.000000" +hcrt_blue_beam_sharpness = "1.300000" +hcrt_blue_beam_attack = "1.000000" + diff --git a/hdr/crt-sony-megatron-sony-pvm-2730-hdr-NTSC.slangp b/hdr/crt-sony-megatron-sony-pvm-2730-hdr-NTSC.slangp new file mode 100644 index 0000000..cfc13b7 --- /dev/null +++ b/hdr/crt-sony-megatron-sony-pvm-2730-hdr-NTSC.slangp @@ -0,0 +1,155 @@ +shaders = "12" + +shader0 = "../crt/shaders/guest/advanced/stock.slang" +filter_linear0 = "false" +wrap_mode0 = "clamp_to_border" +mipmap_input0 = "false" +alias0 = "PrePass0" +float_framebuffer0 = "false" +srgb_framebuffer0 = "false" +scale_type_x0 = "source" +scale_x0 = "1.000000" +scale_type_y0 = "source" +scale_y0 = "1.000000" + +shader1 = "../crt/shaders/guest/advanced/ntsc/ntsc-pass1.slang" +filter_linear1 = "false" +wrap_mode1 = "clamp_to_border" +mipmap_input1 = "false" +alias1 = "NPass1" +float_framebuffer1 = "true" +srgb_framebuffer1 = "false" +scale_type_x1 = "source" +scale_x1 = "4.000000" +scale_type_y1 = "source" +scale_y1 = "1.000000" + +shader2 = "../crt/shaders/guest/advanced/ntsc/ntsc-pass2.slang" +filter_linear2 = "true" +wrap_mode2 = "clamp_to_border" +mipmap_input2 = "false" +alias2 = "" +float_framebuffer2 = "true" +srgb_framebuffer2 = "false" +scale_type_x2 = "source" +scale_x2 = "0.500000" +scale_type_y2 = "source" +scale_y2 = "1.000000" + +shader3 = "../crt/shaders/guest/advanced/ntsc/ntsc-pass3.slang" +filter_linear3 = "true" +wrap_mode3 = "clamp_to_border" +mipmap_input3 = "false" +alias3 = "" +float_framebuffer3 = "false" +srgb_framebuffer3 = "false" +scale_type_x3 = "source" +scale_x3 = "1.000000" +scale_type_y3 = "source" +scale_y3 = "1.000000" + +shader4 = "../crt/shaders/guest/advanced/custom-fast-sharpen.slang" +filter_linear4 = "true" +wrap_mode4 = "clamp_to_border" +mipmap_input4 = "false" +alias4 = "NtscPass" +float_framebuffer4 = "false" +srgb_framebuffer4 = "false" +scale_type_x4 = "source" +scale_x4 = "1.000000" +scale_type_y4 = "source" +scale_y4 = "1.000000" + +shader5 = "../crt/shaders/guest/advanced/stock.slang" +filter_linear5 = "true" +wrap_mode5 = "clamp_to_border" +mipmap_input5 = "true" +alias5 = "PrePass" +float_framebuffer5 = "false" +srgb_framebuffer5 = "false" +scale_type_x5 = "source" +scale_x5 = "1.000000" +scale_type_y5 = "source" +scale_y5 = "1.000000" + +shader6 = "../crt/shaders/guest/advanced/stock.slang" +filter_linear6 = "true" +wrap_mode6 = "clamp_to_border" +mipmap_input6 = "true" +alias6 = "AvgLumPass" +float_framebuffer6 = "false" +srgb_framebuffer6 = "false" +scale_type_x6 = "source" +scale_x6 = "1.000000" +scale_type_y6 = "source" +scale_y6 = "1.000000" + +shader7 = "../crt/shaders/guest/advanced/stock.slang" +filter_linear7 = "true" +wrap_mode7 = "clamp_to_border" +mipmap_input7 = "false" +alias7 = "LinearizePass" +float_framebuffer7 = "true" +srgb_framebuffer7 = "false" +scale_type_x7 = "source" +scale_x7 = "1.000000" +scale_type_y7 = "source" +scale_y7 = "1.000000" + +shader8 = "../crt/shaders/guest/advanced/crt-guest-advanced-ntsc-pass1.slang" +filter_linear8 = "true" +wrap_mode8 = "clamp_to_border" +mipmap_input8 = "false" +alias8 = "Pass1" +float_framebuffer8 = "true" +srgb_framebuffer8 = "false" +scale_type_x8 = "viewport" +scale_x8 = "1.000000" +scale_type_y8 = "source" +scale_y8 = "1.000000" + +shader9 = "shaders/crt-sony-megatron-source-pass.slang" +filter_linear9 = "false" +scale_type9 = "source" +scale9 = "1.0" +wrap_mode9 = "clamp_to_border" +mipmap_input9 = "false" +alias9 = "SourceSDR" + +shader10 = "shaders/crt-sony-megatron-hdr-pass.slang" +filter_linear10 = "false" +scale_type10 = "source" +scale10 = "1.0" +wrap_mode10 = "clamp_to_border" +mipmap_input10 = "false" +alias10 = "SourceHDR" + +shader11 = "shaders/crt-sony-megatron.slang" +filter_linear11 = "false" +wrap_mode11 = "clamp_to_border" +mipmap_input11 = "false" +alias11 = "" +float_framebuffer11 = "false" +srgb_framebuffer11 = "false" + +hcrt_brightness = "0.150000" +hcrt_colour_system = "3.000000" +hcrt_expand_gamut = "1.000000" +hcrt_red_vertical_convergence = "-0.140000" +hcrt_green_vertical_convergence = "0.000000" +hcrt_blue_vertical_convergence = "0.000000" +hcrt_red_scanline_min = "0.550000" +hcrt_red_scanline_max = "0.820000" +hcrt_red_scanline_attack = "0.650000" +hcrt_green_scanline_min = "0.550000" +hcrt_green_scanline_max = "0.900000" +hcrt_green_scanline_attack = "0.130000" +hcrt_blue_scanline_min = "0.720000" +hcrt_blue_scanline_max = "1.000000" +hcrt_blue_scanline_attack = "0.650000" +hcrt_red_beam_sharpness = "1.750000" +hcrt_red_beam_attack = "0.7200000" +hcrt_green_beam_sharpness = "1.600000" +hcrt_green_beam_attack = "0.800000" +hcrt_blue_beam_sharpness = "1.900000" +hcrt_blue_beam_attack = "0.450000" diff --git a/hdr/shaders/crt-guest-advanced-ntsc-pass1a.slang b/hdr/shaders/crt-guest-advanced-ntsc-pass1a.slang new file mode 100644 index 0000000..99c5ae8 --- /dev/null +++ b/hdr/shaders/crt-guest-advanced-ntsc-pass1a.slang @@ -0,0 +1,162 @@ +#version 450 + +/* + CRT - Guest - NTSC - Pass1 (Decoupled) + + Copyright (C) 2018-2022 guest(r) - guest.r@gmail.com + + Incorporates many good ideas and suggestions from Dr. Venom. + I would also like give thanks to many Libretro forums members for continuous feedback, suggestions and caring about the shader. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; + float SIGMA_HOR; + float HSHARPNESS; + float S_SHARP; + float HARNG; + float HSHARP; + float spike; + float internal_res; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + + +#pragma parameter bogus_filtering "[ FILTERING OPTIONS ]: " 0.0 0.0 1.0 1.0 + +#pragma parameter HSHARPNESS " Horizontal Filter Range" 1.5 1.0 8.0 0.05 +#define HSHARPNESS params.HSHARPNESS + +#pragma parameter SIGMA_HOR " Horizontal Blur Sigma" 0.90 0.1 7.0 0.05 +#define SIGMA_HOR params.SIGMA_HOR + +#pragma parameter S_SHARP " Substractive Sharpness" 0.9 0.0 2.0 0.10 +#define S_SHARP params.S_SHARP + +#pragma parameter HSHARP " Sharpness Definition" 1.2 0.0 2.0 0.10 +#define HSHARP params.HSHARP + +#pragma parameter HARNG " Substractive Sharpness Ringing" 0.4 0.0 4.0 0.10 +#define HARNG params.HARNG + +#pragma parameter spike " Scanline Spike Removal" 1.0 0.0 2.0 0.10 +#define spike params.spike + +#define COMPAT_TEXTURE(c,d) texture(c,d) +#define TEX0 vTexCoord + +#define OutputSize params.OutputSize +#define gl_FragCoord (vTexCoord * OutputSize.xy) + +#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 * 1.00001; +} + +#pragma stage fragment +layout(location = 0) in vec2 vTexCoord; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D NtscPass; + +float invsqrsigma = 1.0/(2.0*SIGMA_HOR*SIGMA_HOR); + +float gaussian(float x) +{ + return exp(-x*x*invsqrsigma); +} + +void main() +{ + vec2 prescalex = vec2(textureSize(NtscPass, 0)) / params.OriginalSize.xy; + + vec4 SourceSize = params.OriginalSize * vec4(2.0*prescalex.x, prescalex.y, 0.5/prescalex.x, 1.0/prescalex.y); + + float f = fract(SourceSize.x * vTexCoord.x); + f = 0.5 - f; + vec2 tex = floor(SourceSize.xy * vTexCoord)*SourceSize.zw + 0.5*SourceSize.zw; + vec3 color = 0.0.xxx; + float scolor = 0.0; + vec2 dx = vec2(SourceSize.z, 0.0); + + float w = 0.0; + float swsum = 0.0; + float wsum = 0.0; + vec3 pixel; + + float hsharpness = HSHARPNESS; + vec3 cmax = 0.0.xxx; + vec3 cmin = 1.0.xxx; + float sharp = gaussian(hsharpness) * S_SHARP; + float maxsharp = 0.20; + float FPR = hsharpness; + float fpx = 0.0; + float sp = 0.0; + float sw = 0.0; + + float ts = 0.025; + vec3 luma = vec3(0.2126, 0.7152, 0.0722); + + float LOOPSIZE = ceil(2.0*FPR); + float CLAMPSIZE = round(2.0*LOOPSIZE/3.0); + + float n = -LOOPSIZE; + + do + { + pixel = COMPAT_TEXTURE(NtscPass, tex + n*dx).rgb; + sp = max(max(pixel.r,pixel.g),pixel.b); + + w = gaussian(n+f) - sharp; + fpx = abs(n+f-sign(n)*FPR)/FPR; + if (abs(n) <= CLAMPSIZE) { cmax = max(cmax, pixel); cmin = min(cmin, pixel); } + if (w < 0.0) w = clamp(w, mix(-maxsharp, 0.0, pow(clamp(fpx,0.0,1.0), HSHARP)), 0.0); + + color = color + w * pixel; + wsum = wsum + w; + + sw = max(w, 0.0) * (dot(pixel,luma) + ts); + scolor = scolor + sw * sp; + swsum = swsum + sw; + + n = n + 1.0; + + } while (n <= LOOPSIZE); + + color = color / wsum; + scolor = scolor / swsum; + + color = clamp(mix(clamp(color, cmin, cmax), color, HARNG), 0.0, 1.0); + + scolor = clamp(mix(max(max(color.r, color.g),color.b), scolor, spike), 0.0, 1.0); + + FragColor = vec4(color, scolor); +} \ No newline at end of file