diff --git a/crt.zip b/crt.zip new file mode 100644 index 0000000..305a145 Binary files /dev/null and b/crt.zip differ diff --git a/crt/CRT-beam.glslp b/crt/CRT-beam.glslp new file mode 100644 index 0000000..0aa59a2 --- /dev/null +++ b/crt/CRT-beam.glslp @@ -0,0 +1,10 @@ +shaders = "1" +feedback_pass = "0" +shader0 = "shaders/CRT-Beam.glsl" +filter_linear0 = "true" +wrap_mode0 = "clamp_to_border" +mipmap_input0 = "false" +alias0 = "" +float_framebuffer0 = "false" +srgb_framebuffer0 = "false" + diff --git a/crt/GritsScanlines.glslp b/crt/GritsScanlines.glslp new file mode 100644 index 0000000..9d6896f --- /dev/null +++ b/crt/GritsScanlines.glslp @@ -0,0 +1,18 @@ +shaders = 2 + +shader0 = shaders/GritsScanlines/GritsScanlines.glsl +filter_linear0 = true +scale_type0 = source +scale_x0 = 1.0 +scale_y0 = 4.0 + +shader1 = ../stock.glsl +filter_linear1 = true + +textures = "scanlines_LUT;color_LUT;luminance_LUT" +scanlines_LUT = shaders/GritsScanlines/Scanline-LUT-4px.png +scanlines_LUT_linear = false +color_LUT = ../reshade/shaders/LUT/sony_trinitron_std_50.png +color_LUT_linear = true +luminance_LUT = shaders/GritsScanlines/Fake-Self-Illumination.png +luminance_LUT_linear = true diff --git a/crt/crt-1tap.glslp b/crt/crt-1tap.glslp new file mode 100644 index 0000000..e05b3cd --- /dev/null +++ b/crt/crt-1tap.glslp @@ -0,0 +1,8 @@ +shaders = "1" +shader0 = "shaders/crt-1tap.glsl" +filter_linear0 = "true" +wrap_mode0 = "clamp_to_border" +mipmap_input0 = "false" +alias0 = "" +float_framebuffer0 = "true" +srgb_framebuffer0 = "false" diff --git a/crt/crt-Cyclon.glslp b/crt/crt-Cyclon.glslp new file mode 100644 index 0000000..1338f9c --- /dev/null +++ b/crt/crt-Cyclon.glslp @@ -0,0 +1,8 @@ +shaders = "1" +shader0 = "shaders/crt-Cyclon.glsl" +filter_linear0 = "true" + +textures = bezel +bezel = "shaders/crt-consumer/bezel.png" +bezel_linear = true +bezel_wrap_mode = "clamp_to_edge" diff --git a/crt/crt-aperture.glslp b/crt/crt-aperture.glslp new file mode 100644 index 0000000..4353fac --- /dev/null +++ b/crt/crt-aperture.glslp @@ -0,0 +1,4 @@ +shaders = 1 + +shader0 = shaders/crt-aperture.glsl +filter_linear0 = false diff --git a/crt/crt-blurPi-soft.glslp b/crt/crt-blurPi-soft.glslp new file mode 100644 index 0000000..4ef09c7 --- /dev/null +++ b/crt/crt-blurPi-soft.glslp @@ -0,0 +1,25 @@ +# crt-blurPi slang shader # +# +# Looks good on low res screens (640 x 480 or less), providing screen space scanlines. +# Works great for anbernic handheld devices. +# Use the "soft" variant if you are not using integer scaling +# Made by Oriol Ferrer MesiĆ  (armadillu) +# http://uri.cat +# MIT license + + +shaders = 2 + +shader0 = shaders/crt-blurPi.glsl +filter_linear0 = true +scale_type0 = source +scale0 = 1.0 + +shader1 = shaders/crt-blurPiScanlines.glsl +filter_linear1 = true +scale_type1 = viewport +scale_x1 = 1.0 +scale_y1 = 1.0 + +blurGain = "0.20" +blurRadius = "0.50" diff --git a/crt/crt-blurPi.glslp b/crt/crt-blurPi.glslp new file mode 100644 index 0000000..82d05f3 --- /dev/null +++ b/crt/crt-blurPi.glslp @@ -0,0 +1,25 @@ +# crt-blurPi slang shader # +# +# Looks good on low res screens (640 x 480 or less), providing screen space scanlines. +# Works great for anbernic handheld devices. +# Use the "soft" variant if you are not using integer scaling +# Made by Oriol Ferrer MesiĆ  (armadillu) +# http://uri.cat +# MIT license + + +shaders = 2 + +shader0 = shaders/crt-blurPi.glsl +filter_linear0 = true +scale_type0 = source +scale0 = 1.0 + +shader1 = shaders/crt-blurPiScanlines.glsl +filter_linear1 = false +scale_type1 = viewport +scale_x1 = 1.0 +scale_y1 = 1.0 + +blurGain = "0.20" +blurRadius = "0.50" diff --git a/crt/crt-caligari.glslp b/crt/crt-caligari.glslp new file mode 100644 index 0000000..ca657b1 --- /dev/null +++ b/crt/crt-caligari.glslp @@ -0,0 +1,4 @@ +shaders = 1 + +shader0 = shaders/crt-caligari.glsl +filter_linear0 = false diff --git a/crt/crt-cgwg-fast.glslp b/crt/crt-cgwg-fast.glslp new file mode 100644 index 0000000..c349bc6 --- /dev/null +++ b/crt/crt-cgwg-fast.glslp @@ -0,0 +1,4 @@ +shaders = 1 + +shader0 = shaders/crt-cgwg-fast.glsl +filter_linear0 = false diff --git a/crt/crt-consumer.glslp b/crt/crt-consumer.glslp new file mode 100644 index 0000000..b80d039 --- /dev/null +++ b/crt/crt-consumer.glslp @@ -0,0 +1,13 @@ +shaders = "5" +feedback_pass = "0" +shader0 = "../misc/shaders/convergence.glsl" +filter_linear0 = "true" +shader1 = "../crt/shaders/crt-consumer/linearize.glsl" +filter_linear1 = "false" +shader2 = "../crt/shaders/crt-consumer/glow_x.glsl" +filter_linear2 = "true" +shader3 = "../crt/shaders/crt-consumer/glow_y.glsl" +filter_linear3 = "true" +shader4 = "../crt/shaders/crt-consumer/crt-consumer.glsl" +filter_linear4 = "true" + diff --git a/crt/crt-easymode-halation.glslp b/crt/crt-easymode-halation.glslp new file mode 100644 index 0000000..dcb7130 --- /dev/null +++ b/crt/crt-easymode-halation.glslp @@ -0,0 +1,37 @@ +shaders = "5" + +shader0 = "shaders/crt-easymode-halation/linearize.glsl" +filter_linear0 = "false" +srgb_framebuffer0 = "true" +scale_type_x0 = "source" +scale_x0 = "1.000000" +scale_type_y0 = "source" +scale_y0 = "1.000000" + +shader1 = "shaders/crt-easymode-halation/blur_horiz.glsl" +filter_linear1 = "false" +srgb_framebuffer1 = "true" +scale_type_x1 = "source" +scale_x1 = "1.000000" +scale_type_y1 = "source" +scale_y1 = "1.000000" + +shader2 = "shaders/crt-easymode-halation/blur_vert.glsl" +filter_linear2 = "false" +srgb_framebuffer2 = "true" +scale_type_x2 = "source" +scale_x2 = "1.000000" +scale_type_y2 = "source" +scale_y2 = "1.000000" + +shader3 = "shaders/crt-easymode-halation/threshold.glsl" +filter_linear3 = "false" +srgb_framebuffer3 = "true" +scale_type_x3 = "source" +scale_x3 = "1.000000" +scale_type_y3 = "source" +scale_y3 = "1.000000" + +shader4 = "shaders/crt-easymode-halation/crt-easymode-halation.glsl" +filter_linear4 = "true" + diff --git a/crt/crt-easymode.glslp b/crt/crt-easymode.glslp new file mode 100644 index 0000000..be615ae --- /dev/null +++ b/crt/crt-easymode.glslp @@ -0,0 +1,4 @@ +shaders = 1 + +shader0 = shaders/crt-easymode.glsl +filter_linear0 = false diff --git a/crt/crt-gdv-mini.glslp b/crt/crt-gdv-mini.glslp new file mode 100644 index 0000000..9fde841 --- /dev/null +++ b/crt/crt-gdv-mini.glslp @@ -0,0 +1,4 @@ +shaders = "1" +feedback_pass = "0" +shader0 = shaders/crt-gdv-mini.glsl +filter_linear0 = "true" diff --git a/crt/crt-geom-mini.glslp b/crt/crt-geom-mini.glslp new file mode 100644 index 0000000..e878298 --- /dev/null +++ b/crt/crt-geom-mini.glslp @@ -0,0 +1,3 @@ +shaders = 1 +shader0 = shaders/crt-geom-mini.glsl +filter_linear0 = true diff --git a/crt/crt-geom.glslp b/crt/crt-geom.glslp new file mode 100644 index 0000000..8d9ed35 --- /dev/null +++ b/crt/crt-geom.glslp @@ -0,0 +1,4 @@ +shaders = 1 + +shader0 = shaders/crt-geom.glsl +filter_linear0 = false diff --git a/crt/crt-guest-dr-venom-fast.glslp b/crt/crt-guest-dr-venom-fast.glslp new file mode 100644 index 0000000..6f77527 --- /dev/null +++ b/crt/crt-guest-dr-venom-fast.glslp @@ -0,0 +1,39 @@ +shaders = 5 + +shader0 = shaders/guest/lut/lut.glsl +filter_linear0 = false +scale_type0 = source +scale0 = 1.0 + +textures = "SamplerLUT1;SamplerLUT2;SamplerLUT3" +SamplerLUT1 = shaders/guest/lut/sony_trinitron1.png +SamplerLUT1_linear = true +SamplerLUT2 = shaders/guest/lut/sony_trinitron2.png +SamplerLUT2_linear = true +SamplerLUT3 = shaders/guest/lut/other1.png +SamplerLUT3_linear = true + +shader1 = shaders/guest/fast/smoothing.glsl +filter_linear1 = false +scale_type1 = source +scale1 = 1.0 + +shader2 = shaders/guest/fast/linearize-multipass.glsl +filter_linear2 = false +scale_type2 = source +scale2 = 1.0 +float_framebuffer2 = true + +shader3 = shaders/guest/fast/crt-guest-dr-venom-pass1.glsl +filter_linear3 = false +scale_type_x3 = viewport +scale_x3 = 1.0 +scale_type_y3 = source +scale_y3 = 1.0 +float_framebuffer3 = true + +shader4 = shaders/guest/fast/crt-guest-dr-venom-pass2.glsl +filter_linear4 = false +scale_type4 = viewport +scale_x4 = 1.0 +scale_y4 = 1.0 diff --git a/crt/crt-guest-dr-venom.glslp b/crt/crt-guest-dr-venom.glslp new file mode 100644 index 0000000..582bc09 --- /dev/null +++ b/crt/crt-guest-dr-venom.glslp @@ -0,0 +1,70 @@ +shaders = 11 + +shader0 = shaders/guest/lut/lut.glsl +filter_linear0 = false +scale_type0 = source +scale0 = 1.0 + +textures = "SamplerLUT1;SamplerLUT2;SamplerLUT3" +SamplerLUT1 = shaders/guest/lut/sony_trinitron1.png +SamplerLUT1_linear = true +SamplerLUT2 = shaders/guest/lut/sony_trinitron2.png +SamplerLUT2_linear = true +SamplerLUT3 = shaders/guest/lut/other1.png +SamplerLUT3_linear = true + +shader1 = shaders/guest/color-profiles.glsl +filter_linear1 = false +scale_type1 = source +scale1 = 1.0 + +shader2 = shaders/guest/d65-d50.glsl +filter_linear2 = false +scale_type2 = source +scale2 = 1.0 + +shader3 = shaders/guest/afterglow.glsl +filter_linear3 = false +scale_type3 = source +scale3 = 1.0 + +shader4 = shaders/guest/avg-lum0.glsl +filter_linear4 = false +scale_type4 = source +scale4 = 1.0 + +shader5 = shaders/guest/avg-lum.glsl +filter_linear5 = false +scale_type5 = source +scale5 = 1.0 +mipmap_input5 = true + +shader6 = shaders/guest/linearize.glsl +filter_linear6 = false +scale_type6 = source +scale6 = 1.0 +float_framebuffer6 = true + +shader7 = shaders/guest/blur_horiz.glsl +filter_linear7 = false +scale_type7 = source +scale7 = 1.0 +float_framebuffer7 = true + +shader8 = shaders/guest/blur_vert.glsl +filter_linear8 = false +scale_type8 = source +scale8 = 1.0 +float_framebuffer8 = true + +shader9 = shaders/guest/linearize_scanlines.glsl +filter_linear9 = true +scale_type9 = source +scale9 = 1.0 +float_framebuffer9 = true + +shader10 = shaders/guest/crt-guest-dr-venom.glsl +filter_linear10 = true +scale_type10 = viewport +scale_x10 = 1.0 +scale_y10 = 1.0 \ No newline at end of file diff --git a/crt/crt-guest-sm.glslp b/crt/crt-guest-sm.glslp new file mode 100644 index 0000000..ce72eb9 --- /dev/null +++ b/crt/crt-guest-sm.glslp @@ -0,0 +1,8 @@ +shaders = 2 + +shader0 = shaders/guest/d65-d50.glsl +filter_linear0 = false +scale_type0 = source +scale0 = 1.0 + +shader1 = shaders/guest/crt-guest-sm.glsl diff --git a/crt/crt-hyllian-3d.glslp b/crt/crt-hyllian-3d.glslp new file mode 100644 index 0000000..4f81eb8 --- /dev/null +++ b/crt/crt-hyllian-3d.glslp @@ -0,0 +1,5 @@ +shaders = 1 + +shader0 = shaders/hyllian/crt-hyllian-3d.glsl +filter_linear0 = true +srgb_framebuffer0 = true diff --git a/crt/crt-hyllian-fast.glslp b/crt/crt-hyllian-fast.glslp new file mode 100644 index 0000000..35aad6f --- /dev/null +++ b/crt/crt-hyllian-fast.glslp @@ -0,0 +1,9 @@ +shaders = "1" +feedback_pass = "0" +shader0 = shaders/hyllian/crt-hyllian-fast.glsl +filter_linear0 = "false" +wrap_mode0 = "clamp_to_border" +mipmap_input0 = "false" +alias0 = "" +float_framebuffer0 = "false" +srgb_framebuffer0 = "false" diff --git a/crt/crt-hyllian-glow.glslp b/crt/crt-hyllian-glow.glslp new file mode 100644 index 0000000..4bef5bb --- /dev/null +++ b/crt/crt-hyllian-glow.glslp @@ -0,0 +1,30 @@ +shaders = 6 + +shader0 = shaders/glow/linearize.glsl +filter_linear0 = false +srgb_framebuffer0 = true + +shader1 = shaders/hyllian/crt-hyllian-glow/crt-hyllian-glow.glsl +filter_linear1 = false +scale_type1 = viewport +scale1 = 1.0 +srgb_framebuffer1 = true +alias1 = CRT_PASS + +shader2 = shaders/glow/threshold.glsl +filter_linear2 = false +srgb_framebuffer2 = true + +shader3 = shaders/glow/blur_horiz.glsl +mipmap_input3 = true +filter_linear3 = true +scale_type3 = source +scale3 = 0.25 +srgb_framebuffer3 = true + +shader4 = shaders/glow/blur_vert.glsl +filter_linear4 = true +srgb_framebuffer4 = true + +shader5 = shaders/hyllian/crt-hyllian-glow/resolve2.glsl +filter_linear5 = true diff --git a/crt/crt-hyllian-multipass.glslp b/crt/crt-hyllian-multipass.glslp new file mode 100644 index 0000000..8a2bdbf --- /dev/null +++ b/crt/crt-hyllian-multipass.glslp @@ -0,0 +1,13 @@ +shaders = 2 + +shader0 = shaders/hyllian/crt-hyllian-multipass/crt-hyllian-pass0.glsl +filter_linear0 = false +srgb_framebuffer0 = true +scale_type_x0 = viewport +scale_type_y0 = source +scale_x0 = 1.0 +scale_y0 = 1.0 + +shader1 = shaders/hyllian/crt-hyllian-multipass/crt-hyllian-pass1.glsl +filter_linear1 = false +srgb_framebuffer1 = false diff --git a/crt/crt-hyllian.glslp b/crt/crt-hyllian.glslp new file mode 100644 index 0000000..0f2acd1 --- /dev/null +++ b/crt/crt-hyllian.glslp @@ -0,0 +1,5 @@ +shaders = 1 + +shader0 = shaders/hyllian/crt-hyllian.glsl +filter_linear0 = false +srgb_framebuffer0 = true diff --git a/crt/crt-interlaced-halation.glslp b/crt/crt-interlaced-halation.glslp new file mode 100644 index 0000000..0adbad4 --- /dev/null +++ b/crt/crt-interlaced-halation.glslp @@ -0,0 +1,27 @@ +shaders = "4" + +shader0 = shaders/crt-interlaced-halation/crt-interlaced-halation-pass0.glsl +filter_linear0 = "true" +float_framebuffer0 = "false" +scale_type_x0 = "source" +scale_x0 = "1.000000" +scale_type_y0 = "source" +scale_y0 = "1.000000" +shader1 = shaders/crt-interlaced-halation/crt-interlaced-halation-pass1.glsl +filter_linear1 = "true" +float_framebuffer1 = "false" +scale_type_x1 = "source" +scale_x1 = "1.000000" +scale_type_y1 = "source" +scale_y1 = "1.000000" +shader2 = shaders/crt-interlaced-halation/crt-interlaced-halation-pass2.glsl +filter_linear2 = "true" +float_framebuffer2 = "false" +scale_type_x2 = "source" +scale_x2 = "3.000000" +scale_type_y2 = "source" +scale_y2 = "3.000000" +shader3 = ../interpolation/shaders/quilez.glsl +filter_linear3 = "true" +float_framebuffer3 = "false" + diff --git a/crt/crt-lottes-fast.glslp b/crt/crt-lottes-fast.glslp new file mode 100644 index 0000000..a6877cb --- /dev/null +++ b/crt/crt-lottes-fast.glslp @@ -0,0 +1,4 @@ +shaders = 1 + +shader0 = shaders/crt-lottes-fast.glsl +filter_linear0 = true diff --git a/crt/crt-lottes-mini.glslp b/crt/crt-lottes-mini.glslp new file mode 100644 index 0000000..9e9821b --- /dev/null +++ b/crt/crt-lottes-mini.glslp @@ -0,0 +1,11 @@ +shaders = "2" +feedback_pass = "0" +shader0 = "shaders/crt-consumer/linearize.glsl" +filter_linear0 = "false" +scale_type_x0 = "source" +scale_x0 = "1.000000" +scale_type_y0 = "source" +scale_y0 = "1.000000" +shader1 = "shaders/crt-lottes-mini.glsl" +filter_linear1 = "true" +g_in = 2.2 diff --git a/crt/crt-lottes-multipass.glslp b/crt/crt-lottes-multipass.glslp new file mode 100644 index 0000000..ce4150e --- /dev/null +++ b/crt/crt-lottes-multipass.glslp @@ -0,0 +1,8 @@ +shaders = 2 + +shader0 = shaders/crt-lottes-multipass/bloompass.glsl +alias0 = BloomPass +#doesn't work in GL_ES anyway, AFAICT +srgb_framebuffer0 = true + +shader1 = shaders/crt-lottes-multipass/scanpass.glsl \ No newline at end of file diff --git a/crt/crt-lottes.glslp b/crt/crt-lottes.glslp new file mode 100644 index 0000000..06dc979 --- /dev/null +++ b/crt/crt-lottes.glslp @@ -0,0 +1,4 @@ +shaders = 1 + +shader0 = shaders/crt-lottes.glsl +filter_linear0 = false diff --git a/crt/crt-mattias.glslp b/crt/crt-mattias.glslp new file mode 100644 index 0000000..235c9d0 --- /dev/null +++ b/crt/crt-mattias.glslp @@ -0,0 +1,4 @@ +shaders = 1 + +shader0 = shaders/crt-mattias.glsl +filter_linear0 = false \ No newline at end of file diff --git a/crt/crt-nes-mini.glslp b/crt/crt-nes-mini.glslp new file mode 100644 index 0000000..0c41c03 --- /dev/null +++ b/crt/crt-nes-mini.glslp @@ -0,0 +1,3 @@ +shaders = 1 + +shader0 = shaders/crt-nes-mini.glsl diff --git a/crt/crt-nobody.glslp b/crt/crt-nobody.glslp new file mode 100644 index 0000000..9d943ab --- /dev/null +++ b/crt/crt-nobody.glslp @@ -0,0 +1,4 @@ +shaders = 1 + +shader0 = shaders/crt-nobody.glsl +filter_linear0 = false diff --git a/crt/crt-pi-vertical.glslp b/crt/crt-pi-vertical.glslp new file mode 100644 index 0000000..e64c1b4 --- /dev/null +++ b/crt/crt-pi-vertical.glslp @@ -0,0 +1,8 @@ +shaders = "1" +shader0 = "shaders/crt-pi-vertical.glsl" +filter_linear0 = "true" +wrap_mode0 = "clamp_to_border" +mipmap_input0 = "false" +alias0 = "" +float_framebuffer0 = "false" +srgb_framebuffer0 = "false" diff --git a/crt/crt-pi.glslp b/crt/crt-pi.glslp new file mode 100644 index 0000000..587e110 --- /dev/null +++ b/crt/crt-pi.glslp @@ -0,0 +1,8 @@ +shaders = "1" +shader0 = "shaders/crt-pi.glsl" +filter_linear0 = "true" +wrap_mode0 = "clamp_to_border" +mipmap_input0 = "false" +alias0 = "" +float_framebuffer0 = "false" +srgb_framebuffer0 = "false" diff --git a/crt/crt-potato-BVM.glslp b/crt/crt-potato-BVM.glslp new file mode 100644 index 0000000..eef7834 --- /dev/null +++ b/crt/crt-potato-BVM.glslp @@ -0,0 +1,12 @@ +shaders = 1 + +shader0 = shaders/crt-potato/shader-files/ultra-potato.glsl +filter_linear0 = false +scale_type0 = viewport +scale0 = 1.0 +alias0 = "PASS0" + +textures = MASK +MASK = shaders/crt-potato/resources/mask1.png +MASK_linear = false +MASK_wrap_mode = "repeat" \ No newline at end of file diff --git a/crt/crt-potato-cool.glslp b/crt/crt-potato-cool.glslp new file mode 100644 index 0000000..22bc7cc --- /dev/null +++ b/crt/crt-potato-cool.glslp @@ -0,0 +1,12 @@ +shaders = 1 + +shader0 = shaders/crt-potato/shader-files/crt-potato.glsl +filter_linear0 = false +scale_type0 = viewport +scale0 = 1.0 +alias0 = "PASS0" + +textures = MASK +MASK = shaders/crt-potato/resources/crt-potato-thin.png +MASK_linear = false +MASK_wrap_mode = "repeat" \ No newline at end of file diff --git a/crt/crt-potato-warm.glslp b/crt/crt-potato-warm.glslp new file mode 100644 index 0000000..c883c19 --- /dev/null +++ b/crt/crt-potato-warm.glslp @@ -0,0 +1,12 @@ +shaders = 1 + +shader0 = shaders/crt-potato/shader-files/crt-potato.glsl +filter_linear0 = false +scale_type0 = viewport +scale0 = 1.0 +alias0 = "PASS0" + +textures = MASK +MASK = shaders/crt-potato/resources/crt-potato-thick.png +MASK_linear = false +MASK_wrap_mode = "repeat" \ No newline at end of file diff --git a/crt/crt-royale-fake-bloom-intel.glslp b/crt/crt-royale-fake-bloom-intel.glslp new file mode 100644 index 0000000..e4c7ffc --- /dev/null +++ b/crt/crt-royale-fake-bloom-intel.glslp @@ -0,0 +1,131 @@ +# IMPORTANT: +# Shader passes need to know details about the image in the mask_texture LUT +# files, so set the following constants in user-cgp-constants.h accordingly: +# 1.) mask_triads_per_tile = (number of horizontal triads in mask texture LUT's) +# 2.) mask_texture_small_size = (texture size of mask*texture_small LUT's) +# 3.) mask_texture_large_size = (texture size of mask*texture_large LUT's) +# 4.) mask_grille_avg_color = (avg. brightness of mask_grille_texture* LUT's, in [0, 1]) +# 5.) mask_slot_avg_color = (avg. brightness of mask_slot_texture* LUT's, in [0, 1]) +# 6.) mask_shadow_avg_color = (avg. brightness of mask_shadow_texture* LUT's, in [0, 1]) +# Shader passes also need to know certain scales set in this .glslp, but their +# compilation model doesn't currently allow the .glslp file to tell them. Make +# sure to set the following constants in user-cgp-constants.h accordingly too: +# 1.) bloom_approx_scale_x_for_fake = scale_x2 +# 2.) mask_resize_viewport_scale = float2(scale_x6, scale_y5) +# Finally, shader passes need to know the value of geom_max_aspect_ratio used to +# calculate scale_y5 (among other values): +# 1.) geom_max_aspect_ratio = (geom_max_aspect_ratio used to calculate scale_y5) + +shaders = "7" + +# Set an identifier, filename, and sampling traits for the phosphor mask texture. +# Load an aperture grille, slot mask, and an EDP shadow mask, and load a small +# non-mipmapped version and a large mipmapped version. +# TODO: Test masks in other directories. +textures = "mask_grille_texture_small;mask_grille_texture_large;mask_slot_texture_small;mask_slot_texture_large;mask_shadow_texture_small;mask_shadow_texture_large" +mask_grille_texture_small = "shaders/crt-royale/TileableLinearApertureGrille15Wide8And5d5SpacingResizeTo64.png" +mask_grille_texture_large = "shaders/crt-royale/TileableLinearApertureGrille15Wide8And5d5Spacing.png" +mask_slot_texture_small = "shaders/crt-royale/TileableLinearSlotMaskTall15Wide9And4d5Horizontal9d14VerticalSpacingResizeTo64.png" +mask_slot_texture_large = "shaders/crt-royale/TileableLinearSlotMaskTall15Wide9And4d5Horizontal9d14VerticalSpacing.png" +mask_shadow_texture_small = "shaders/crt-royale/TileableLinearShadowMaskEDPResizeTo64.png" +mask_shadow_texture_large = "shaders/crt-royale/TileableLinearShadowMaskEDP.png" +mask_grille_texture_small_wrap_mode = "repeat" +mask_grille_texture_large_wrap_mode = "repeat" +mask_slot_texture_small_wrap_mode = "repeat" +mask_slot_texture_large_wrap_mode = "repeat" +mask_shadow_texture_small_wrap_mode = "repeat" +mask_shadow_texture_large_wrap_mode = "repeat" +mask_grille_texture_small_linear = "true" +mask_grille_texture_large_linear = "true" +mask_slot_texture_small_linear = "true" +mask_slot_texture_large_linear = "true" +mask_shadow_texture_small_linear = "true" +mask_shadow_texture_large_linear = "true" +mask_grille_texture_small_mipmap = "false" # Mipmapping causes artifacts with manually resized masks without tex2Dlod +mask_grille_texture_large_mipmap = "true" # Essential for hardware-resized masks +mask_slot_texture_small_mipmap = "false" # Mipmapping causes artifacts with manually resized masks without tex2Dlod +mask_slot_texture_large_mipmap = "true" # Essential for hardware-resized masks +mask_shadow_texture_small_mipmap = "false" # Mipmapping causes artifacts with manually resized masks without tex2Dlod +mask_shadow_texture_large_mipmap = "true" # Essential for hardware-resized masks + + +# Pass0: Linearize the input based on CRT gamma and bob interlaced fields. +# (Bobbing ensures we can immediately blur without getting artifacts.) +shader0 = "shaders/crt-royale/src/crt-royale-first-pass-linearize-crt-gamma-bob-fields.glsl" +alias0 = "ORIG_LINEARIZED" +filter_linear0 = "false" +scale_type0 = "source" +scale0 = "1.0" +srgb_framebuffer0 = "true" + +# Pass1: Resample interlaced (and misconverged) scanlines vertically. +# Separating vertical/horizontal scanline sampling is faster: It lets us +# consider more scanlines while calculating weights for fewer pixels, and +# it reduces our samples from vertical*horizontal to vertical+horizontal. +# This has to come right after ORIG_LINEARIZED, because there's no +# "original_source" scale_type we can use later. +shader1 = "shaders/crt-royale/src/crt-royale-scanlines-vertical-interlacing.glsl" +alias1 = "VERTICAL_SCANLINES" +filter_linear1 = "true" +scale_type_x1 = "source" +scale_x1 = "1.0" +scale_type_y1 = "viewport" +scale_y1 = "1.0" +#float_framebuffer1 = "true" +srgb_framebuffer1 = "true" + +# Pass2: Do a small resize blur of ORIG_LINEARIZED at an absolute size, and +# account for convergence offsets. We want to blur a predictable portion of the +# screen to match the phosphor bloom, and absolute scale works best for +# reliable results with a fixed-size bloom. Picking a scale is tricky: +# a.) 400x300 is a good compromise for the "fake-bloom" version: It's low enough +# to blur high-res/interlaced sources but high enough that resampling +# doesn't smear low-res sources too much. +# b.) 320x240 works well for the "real bloom" version: It's 1-1.5% faster, and +# the only noticeable visual difference is a larger halation spread (which +# may be a good thing for people who like to crank it up). +# Note the 4:3 aspect ratio assumes the input has cropped geom_overscan (so it's +# *intended* for an ~4:3 aspect ratio). +shader2 = "shaders/crt-royale/src/crt-royale-bloom-approx-fake-bloom-intel.glsl" +alias2 = "BLOOM_APPROX" +filter_linear2 = "true" +scale_type2 = "absolute" +scale_x2 = "400" +scale_y2 = "300" +srgb_framebuffer2 = "true" + +# Pass3: Vertically blur the input for halation and refractive diffusion. +# Base this on BLOOM_APPROX: This blur should be small and fast, and blurring +# a constant portion of the screen is probably physically correct if the +# viewport resolution is proportional to the simulated CRT size. +shader3 = "../blurs/shaders/royale/blur9fast-vertical.glsl" +filter_linear3 = "true" +scale_type3 = "source" +scale3 = "1.0" +srgb_framebuffer3 = "true" + +# Pass4: Horizontally blur the input for halation and refractive diffusion. +# Note: Using a one-pass 9x9 blur is about 1% slower. +shader4 = "../blurs/shaders/royale/blur9fast-horizontal.glsl" +alias4 = "HALATION_BLUR" +filter_linear4 = "true" +scale_type4 = "source" +scale4 = "1.0" +srgb_framebuffer4 = "true" + +# Pass5: Resample (misconverged) scanlines horizontally, apply halation, and +# apply the phosphor mask, then fake a phosphor bloom, all in one pass. +shader5 = "shaders/crt-royale/src/crt-royale-scanlines-horizontal-apply-mask-fake-bloom-intel.glsl" +alias5 = "MASKED_SCANLINES" +filter_linear5 = "true" # This could just as easily be nearest neighbor. +scale_type5 = "viewport" +scale5 = "1.0" +#float_framebuffer5 = "true" +srgb_framebuffer5 = "true" + +# Pass 6: Compute curvature/AA: +shader6 = "shaders/crt-royale/src/crt-royale-geometry-aa-last-pass-intel.glsl" +filter_linear6 = "true" +scale_type6 = "viewport" +mipmap_input6 = "true" +texture_wrap_mode6 = "clamp_to_edge" diff --git a/crt/crt-royale-fake-bloom.glslp b/crt/crt-royale-fake-bloom.glslp new file mode 100644 index 0000000..c2a6314 --- /dev/null +++ b/crt/crt-royale-fake-bloom.glslp @@ -0,0 +1,183 @@ +# IMPORTANT: +# Shader passes need to know details about the image in the mask_texture LUT +# files, so set the following constants in user-cgp-constants.h accordingly: +# 1.) mask_triads_per_tile = (number of horizontal triads in mask texture LUT's) +# 2.) mask_texture_small_size = (texture size of mask*texture_small LUT's) +# 3.) mask_texture_large_size = (texture size of mask*texture_large LUT's) +# 4.) mask_grille_avg_color = (avg. brightness of mask_grille_texture* LUT's, in [0, 1]) +# 5.) mask_slot_avg_color = (avg. brightness of mask_slot_texture* LUT's, in [0, 1]) +# 6.) mask_shadow_avg_color = (avg. brightness of mask_shadow_texture* LUT's, in [0, 1]) +# Shader passes also need to know certain scales set in this .glslp, but their +# compilation model doesn't currently allow the .glslp file to tell them. Make +# sure to set the following constants in user-cgp-constants.h accordingly too: +# 1.) bloom_approx_scale_x_for_fake = scale_x2 +# 2.) mask_resize_viewport_scale = float2(scale_x6, scale_y5) +# Finally, shader passes need to know the value of geom_max_aspect_ratio used to +# calculate scale_y5 (among other values): +# 1.) geom_max_aspect_ratio = (geom_max_aspect_ratio used to calculate scale_y5) + +shaders = "9" + +# Set an identifier, filename, and sampling traits for the phosphor mask texture. +# Load an aperture grille, slot mask, and an EDP shadow mask, and load a small +# non-mipmapped version and a large mipmapped version. +# TODO: Test masks in other directories. +textures = "mask_grille_texture_small;mask_grille_texture_large;mask_slot_texture_small;mask_slot_texture_large;mask_shadow_texture_small;mask_shadow_texture_large" +mask_grille_texture_small = "shaders/crt-royale/TileableLinearApertureGrille15Wide8And5d5SpacingResizeTo64.png" +mask_grille_texture_large = "shaders/crt-royale/TileableLinearApertureGrille15Wide8And5d5Spacing.png" +mask_slot_texture_small = "shaders/crt-royale/TileableLinearSlotMaskTall15Wide9And4d5Horizontal9d14VerticalSpacingResizeTo64.png" +mask_slot_texture_large = "shaders/crt-royale/TileableLinearSlotMaskTall15Wide9And4d5Horizontal9d14VerticalSpacing.png" +mask_shadow_texture_small = "shaders/crt-royale/TileableLinearShadowMaskEDPResizeTo64.png" +mask_shadow_texture_large = "shaders/crt-royale/TileableLinearShadowMaskEDP.png" +mask_grille_texture_small_wrap_mode = "repeat" +mask_grille_texture_large_wrap_mode = "repeat" +mask_slot_texture_small_wrap_mode = "repeat" +mask_slot_texture_large_wrap_mode = "repeat" +mask_shadow_texture_small_wrap_mode = "repeat" +mask_shadow_texture_large_wrap_mode = "repeat" +mask_grille_texture_small_linear = "true" +mask_grille_texture_large_linear = "true" +mask_slot_texture_small_linear = "true" +mask_slot_texture_large_linear = "true" +mask_shadow_texture_small_linear = "true" +mask_shadow_texture_large_linear = "true" +mask_grille_texture_small_mipmap = "false" # Mipmapping causes artifacts with manually resized masks without tex2Dlod +mask_grille_texture_large_mipmap = "true" # Essential for hardware-resized masks +mask_slot_texture_small_mipmap = "false" # Mipmapping causes artifacts with manually resized masks without tex2Dlod +mask_slot_texture_large_mipmap = "true" # Essential for hardware-resized masks +mask_shadow_texture_small_mipmap = "false" # Mipmapping causes artifacts with manually resized masks without tex2Dlod +mask_shadow_texture_large_mipmap = "true" # Essential for hardware-resized masks + + +# Pass0: Linearize the input based on CRT gamma and bob interlaced fields. +# (Bobbing ensures we can immediately blur without getting artifacts.) +shader0 = "shaders/crt-royale/src/crt-royale-first-pass-linearize-crt-gamma-bob-fields.glsl" +alias0 = "ORIG_LINEARIZED" +filter_linear0 = "false" +scale_type0 = "source" +scale0 = "1.0" +srgb_framebuffer0 = "true" + +# Pass1: Resample interlaced (and misconverged) scanlines vertically. +# Separating vertical/horizontal scanline sampling is faster: It lets us +# consider more scanlines while calculating weights for fewer pixels, and +# it reduces our samples from vertical*horizontal to vertical+horizontal. +# This has to come right after ORIG_LINEARIZED, because there's no +# "original_source" scale_type we can use later. +shader1 = "shaders/crt-royale/src/crt-royale-scanlines-vertical-interlacing.glsl" +alias1 = "VERTICAL_SCANLINES" +filter_linear1 = "true" +scale_type_x1 = "source" +scale_x1 = "1.0" +scale_type_y1 = "viewport" +scale_y1 = "1.0" +#float_framebuffer1 = "true" +srgb_framebuffer1 = "true" + +# Pass2: Do a small resize blur of ORIG_LINEARIZED at an absolute size, and +# account for convergence offsets. We want to blur a predictable portion of the +# screen to match the phosphor bloom, and absolute scale works best for +# reliable results with a fixed-size bloom. Picking a scale is tricky: +# a.) 400x300 is a good compromise for the "fake-bloom" version: It's low enough +# to blur high-res/interlaced sources but high enough that resampling +# doesn't smear low-res sources too much. +# b.) 320x240 works well for the "real bloom" version: It's 1-1.5% faster, and +# the only noticeable visual difference is a larger halation spread (which +# may be a good thing for people who like to crank it up). +# Note the 4:3 aspect ratio assumes the input has cropped geom_overscan (so it's +# *intended* for an ~4:3 aspect ratio). +shader2 = "shaders/crt-royale/src/crt-royale-bloom-approx-fake-bloom.glsl" +alias2 = "BLOOM_APPROX" +filter_linear2 = "true" +scale_type2 = "absolute" +scale_x2 = "400" +scale_y2 = "300" +srgb_framebuffer2 = "true" + +# Pass3: Vertically blur the input for halation and refractive diffusion. +# Base this on BLOOM_APPROX: This blur should be small and fast, and blurring +# a constant portion of the screen is probably physically correct if the +# viewport resolution is proportional to the simulated CRT size. +shader3 = "../blurs/shaders/royale/blur9fast-vertical.glsl" +filter_linear3 = "true" +scale_type3 = "source" +scale3 = "1.0" +srgb_framebuffer3 = "true" + +# Pass4: Horizontally blur the input for halation and refractive diffusion. +# Note: Using a one-pass 9x9 blur is about 1% slower. +shader4 = "../blurs/shaders/royale/blur9fast-horizontal.glsl" +alias4 = "HALATION_BLUR" +filter_linear4 = "true" +scale_type4 = "source" +scale4 = "1.0" +srgb_framebuffer4 = "true" + +# Pass5: Lanczos-resize the phosphor mask vertically. Set the absolute +# scale_x5 == mask_texture_small_size.x (see IMPORTANT above). Larger scales +# will blur, and smaller scales could get nasty. The vertical size must be +# based on the viewport size and calculated carefully to avoid artifacts later. +# First calculate the minimum number of mask tiles we need to draw. +# Since curvature is computed after the scanline masking pass: +# num_resized_mask_tiles = 2.0; +# If curvature were computed in the scanline masking pass (it's not): +# max_mask_texel_border = ~3.0 * (1/3.0 + 4.0*sqrt(2.0) + 0.5 + 1.0); +# max_mask_tile_border = max_mask_texel_border/ +# (min_resized_phosphor_triad_size * mask_triads_per_tile); +# num_resized_mask_tiles = max(2.0, 1.0 + max_mask_tile_border * 2.0); +# At typical values (triad_size >= 2.0, mask_triads_per_tile == 8): +# num_resized_mask_tiles = ~3.8 +# Triad sizes are given in horizontal terms, so we need geom_max_aspect_ratio +# to relate them to vertical resolution. The widest we expect is: +# geom_max_aspect_ratio = 4.0/3.0 # Note: Shader passes need to know this! +# The fewer triads we tile across the screen, the larger each triad will be as a +# fraction of the viewport size, and the larger scale_y5 must be to draw a full +# num_resized_mask_tiles. Therefore, we must decide the smallest number of +# triads we'll guarantee can be displayed on screen. We'll set this according +# to 3-pixel triads at 768p resolution (the lowest anyone's likely to use): +# min_allowed_viewport_triads = 768.0*geom_max_aspect_ratio / 3.0 = 341.333333 +# Now calculate the viewport scale that ensures we can draw resized_mask_tiles: +# min_scale_x = resized_mask_tiles * mask_triads_per_tile / +# min_allowed_viewport_triads +# scale_y5 = geom_max_aspect_ratio * min_scale_x +# # Some code might depend on equal scales: +# scale_x6 = scale_y5 +# Given our default geom_max_aspect_ratio and min_allowed_viewport_triads: +# scale_y5 = 4.0/3.0 * 2.0/(341.33333 / 8.0) = 0.0625 +# IMPORTANT: The scales MUST be calculated in this way. If you wish to change +# geom_max_aspect_ratio, update that constant in user-cgp-constants.h! +shader5 = "shaders/crt-royale/src/crt-royale-mask-resize-vertical.glsl" +filter_linear5 = "true" +scale_type_x5 = "absolute" +scale_x5 = "64" +scale_type_y5 = "viewport" +scale_y5 = "0.0625" # Safe for >= 341.333 horizontal triads at viewport size +#srgb_framebuffer5 = "false" # mask_texture is already assumed linear + +# Pass6: Lanczos-resize the phosphor mask horizontally. scale_x6 = scale_y5. +# TODO: Check again if the shaders actually require equal scales. +shader6 = "shaders/crt-royale/src/crt-royale-mask-resize-horizontal.glsl" +alias6 = "MASK_RESIZE" +filter_linear6 = "false" +scale_type_x6 = "viewport" +scale_x6 = "0.0625" +scale_type_y6 = "source" +scale_y6 = "1.0" +#srgb_framebuffer6 = "false" # mask_texture is already assumed linear + +# Pass7: Resample (misconverged) scanlines horizontally, apply halation, and +# apply the phosphor mask, then fake a phosphor bloom, all in one pass. +shader7 = "shaders/crt-royale/src/crt-royale-scanlines-horizontal-apply-mask-fake-bloom.glsl" +alias7 = "MASKED_SCANLINES" +filter_linear7 = "true" # This could just as easily be nearest neighbor. +scale_type7 = "viewport" +scale7 = "1.0" +#float_framebuffer7 = "true" +srgb_framebuffer7 = "true" + +# Pass 8: Compute curvature/AA: +shader8 = "shaders/crt-royale/src/crt-royale-geometry-aa-last-pass.glsl" +filter_linear8 = "true" +scale_type8 = "viewport" +mipmap_input8 = "true" +texture_wrap_mode8 = "clamp_to_edge" diff --git a/crt/crt-royale-ntsc-256px-composite.glslp b/crt/crt-royale-ntsc-256px-composite.glslp new file mode 100644 index 0000000..602bc2a --- /dev/null +++ b/crt/crt-royale-ntsc-256px-composite.glslp @@ -0,0 +1,224 @@ +# IMPORTANT: +# Shader passes need to know details about the image in the mask_texture LUT +# files, so set the following constants in user-cgp-constants.h accordingly: +# 1.) mask_triads_per_tile = (number of horizontal triads in mask texture LUT's) +# 2.) mask_texture_small_size = (texture size of mask*texture_small LUT's) +# 3.) mask_texture_large_size = (texture size of mask*texture_large LUT's) +# 4.) mask_grille_avg_color = (avg. brightness of mask_grille_texture* LUT's, in [0, 1]) +# 5.) mask_slot_avg_color = (avg. brightness of mask_slot_texture* LUT's, in [0, 1]) +# 6.) mask_shadow_avg_color = (avg. brightness of mask_shadow_texture* LUT's, in [0, 1]) +# Shader passes also need to know certain scales set in this .glslp, but their +# compilation model doesn't currently allow the .glslp file to tell them. Make +# sure to set the following constants in user-cgp-constants.h accordingly too: +# 1.) bloom_approx_scale_x = scale_x2 +# 2.) mask_resize_viewport_scale = float2(scale_x6, scale_y5) +# Finally, shader passes need to know the value of geom_max_aspect_ratio used to +# calculate scale_y5 (among other values): +# 1.) geom_max_aspect_ratio = (geom_max_aspect_ratio used to calculate scale_y5) + +shaders = "14" + +# NTSC Shader Passes +shader0 = "../ntsc/shaders/ntsc-pass1-composite-3phase.glsl" +shader1 = "../ntsc/shaders/ntsc-pass2-3phase.glsl" + +filter_linear0 = false +filter_linear1 = false + +scale_type_x0 = absolute +scale_type_y0 = source +scale_x0 = 1024 +scale_y0 = 1.0 +frame_count_mod0 = 2 +float_framebuffer0 = true + +scale_type1 = source +scale_x1 = 0.5 +scale_y1 = 1.0 + +# Set an identifier, filename, and sampling traits for the phosphor mask texture. +# Load an aperture grille, slot mask, and an EDP shadow mask, and load a small +# non-mipmapped version and a large mipmapped version. +# TODO: Test masks in other directories. +textures = "mask_grille_texture_small;mask_grille_texture_large;mask_slot_texture_small;mask_slot_texture_large;mask_shadow_texture_small;mask_shadow_texture_large" +mask_grille_texture_small = "shaders/crt-royale/TileableLinearApertureGrille15Wide8And5d5SpacingResizeTo64.png" +mask_grille_texture_large = "shaders/crt-royale/TileableLinearApertureGrille15Wide8And5d5Spacing.png" +mask_slot_texture_small = "shaders/crt-royale/TileableLinearSlotMaskTall15Wide9And4d5Horizontal9d14VerticalSpacingResizeTo64.png" +mask_slot_texture_large = "shaders/crt-royale/TileableLinearSlotMaskTall15Wide9And4d5Horizontal9d14VerticalSpacing.png" +mask_shadow_texture_small = "shaders/crt-royale/TileableLinearShadowMaskEDPResizeTo64.png" +mask_shadow_texture_large = "shaders/crt-royale/TileableLinearShadowMaskEDP.png" +mask_grille_texture_small_wrap_mode = "repeat" +mask_grille_texture_large_wrap_mode = "repeat" +mask_slot_texture_small_wrap_mode = "repeat" +mask_slot_texture_large_wrap_mode = "repeat" +mask_shadow_texture_small_wrap_mode = "repeat" +mask_shadow_texture_large_wrap_mode = "repeat" +mask_grille_texture_small_linear = "true" +mask_grille_texture_large_linear = "true" +mask_slot_texture_small_linear = "true" +mask_slot_texture_large_linear = "true" +mask_shadow_texture_small_linear = "true" +mask_shadow_texture_large_linear = "true" +mask_grille_texture_small_mipmap = "false" # Mipmapping causes artifacts with manually resized masks without tex2Dlod +mask_grille_texture_large_mipmap = "true" # Essential for hardware-resized masks +mask_slot_texture_small_mipmap = "false" # Mipmapping causes artifacts with manually resized masks without tex2Dlod +mask_slot_texture_large_mipmap = "true" # Essential for hardware-resized masks +mask_shadow_texture_small_mipmap = "false" # Mipmapping causes artifacts with manually resized masks without tex2Dlod +mask_shadow_texture_large_mipmap = "true" # Essential for hardware-resized masks + + +# Pass2: Linearize the input based on CRT gamma and bob interlaced fields. +# (Bobbing ensures we can immediately blur without getting artifacts.) +shader2 = "shaders/crt-royale/src/crt-royale-first-pass-linearize-crt-gamma-bob-fields.glsl" +alias2 = "ORIG_LINEARIZED" +filter_linear2 = "false" +scale_type2 = "source" +scale2 = "1.0" +srgb_framebuffer2 = "true" + +# Pass3: Resample interlaced (and misconverged) scanlines vertically. +# Separating vertical/horizontal scanline sampling is faster: It lets us +# consider more scanlines while calculating weights for fewer pixels, and +# it reduces our samples from vertical*horizontal to vertical+horizontal. +# This has to come right after ORIG_LINEARIZED, because there's no +# "original_source" scale_type we can use later. +shader3 = "shaders/crt-royale/src/crt-royale-scanlines-vertical-interlacing.glsl" +alias3 = "VERTICAL_SCANLINES" +filter_linear3 = "true" +scale_type_x3 = "source" +scale_x3 = "1.0" +scale_type_y3 = "viewport" +scale_y3 = "1.0" +#float_framebuffer3 = "true" +srgb_framebuffer3 = "true" + +# Pass4: Do a small resize blur of ORIG_LINEARIZED at an absolute size, and +# account for convergence offsets. We want to blur a predictable portion of the +# screen to match the phosphor bloom, and absolute scale works best for +# reliable results with a fixed-size bloom. Picking a scale is tricky: +# a.) 400x300 is a good compromise for the "fake-bloom" version: It's low enough +# to blur high-res/interlaced sources but high enough that resampling +# doesn't smear low-res sources too much. +# b.) 320x240 works well for the "real bloom" version: It's 1-1.5% faster, and +# the only noticeable visual difference is a larger halation spread (which +# may be a good thing for people who like to crank it up). +# Note the 4:3 aspect ratio assumes the input has cropped geom_overscan (so it's +# *intended* for an ~4:3 aspect ratio). +shader4 = "shaders/crt-royale/src/crt-royale-bloom-approx.glsl" +alias4 = "BLOOM_APPROX" +filter_linear4 = "true" +scale_type4 = "absolute" +scale_x4 = "320" +scale_y4 = "240" +srgb_framebuffer4 = "true" + +# Pass5: Vertically blur the input for halation and refractive diffusion. +# Base this on BLOOM_APPROX: This blur should be small and fast, and blurring +# a constant portion of the screen is probably physically correct if the +# viewport resolution is proportional to the simulated CRT size. +shader5 = "../blurs/shaders/royale/blur9fast-vertical.glsl" +filter_linear5 = "true" +scale_type5 = "source" +scale5 = "1.0" +srgb_framebuffer5 = "true" + +# Pass6: Horizontally blur the input for halation and refractive diffusion. +# Note: Using a one-pass 9x9 blur is about 1% slower. +shader6 = "../blurs/shaders/royale/blur9fast-horizontal.glsl" +alias6 = "HALATION_BLUR" +filter_linear6 = "true" +scale_type6 = "source" +scale6 = "1.0" +srgb_framebuffer6 = "true" + +# Pass7: Lanczos-resize the phosphor mask vertically. Set the absolute +# scale_x7 == mask_texture_small_size.x (see IMPORTANT above). Larger scales +# will blur, and smaller scales could get nasty. The vertical size must be +# based on the viewport size and calculated carefully to avoid artifacts later. +# First calculate the minimum number of mask tiles we need to draw. +# Since curvature is computed after the scanline masking pass: +# num_resized_mask_tiles = 2.0; +# If curvature were computed in the scanline masking pass (it's not): +# max_mask_texel_border = ~3.0 * (1/3.0 + 4.0*sqrt(2.0) + 0.5 + 1.0); +# max_mask_tile_border = max_mask_texel_border/ +# (min_resized_phosphor_triad_size * mask_triads_per_tile); +# num_resized_mask_tiles = max(2.0, 1.0 + max_mask_tile_border * 2.0); +# At typical values (triad_size >= 2.0, mask_triads_per_tile == 8): +# num_resized_mask_tiles = ~3.8 +# Triad sizes are given in horizontal terms, so we need geom_max_aspect_ratio +# to relate them to vertical resolution. The widest we expect is: +# geom_max_aspect_ratio = 4.0/3.0 # Note: Shader passes need to know this! +# The fewer triads we tile across the screen, the larger each triad will be as a +# fraction of the viewport size, and the larger scale_y5 must be to draw a full +# num_resized_mask_tiles. Therefore, we must decide the smallest number of +# triads we'll guarantee can be displayed on screen. We'll set this according +# to 3-pixel triads at 768p resolution (the lowest anyone's likely to use): +# min_allowed_viewport_triads = 768.0*geom_max_aspect_ratio / 3.0 = 341.333333 +# Now calculate the viewport scale that ensures we can draw resized_mask_tiles: +# min_scale_x = resized_mask_tiles * mask_triads_per_tile / +# min_allowed_viewport_triads +# scale_y7 = geom_max_aspect_ratio * min_scale_x +# # Some code might depend on equal scales: +# scale_x8 = scale_y7 +# Given our default geom_max_aspect_ratio and min_allowed_viewport_triads: +# scale_y7 = 4.0/3.0 * 2.0/(341.33333 / 8.0) = 0.0625 +# IMPORTANT: The scales MUST be calculated in this way. If you wish to change +# geom_max_aspect_ratio, update that constant in user-cgp-constants.h! +shader7 = "shaders/crt-royale/src/crt-royale-mask-resize-vertical.glsl" +filter_linear7 = "true" +scale_type_x7 = "absolute" +scale_x7 = "64" +scale_type_y7 = "viewport" +scale_y7 = "0.0625" # Safe for >= 341.333 horizontal triads at viewport size +#srgb_framebuffer7 = "false" # mask_texture is already assumed linear + +# Pass8: Lanczos-resize the phosphor mask horizontally. scale_x8 = scale_y7. +# TODO: Check again if the shaders actually require equal scales. +shader8 = "shaders/crt-royale/src/crt-royale-mask-resize-horizontal.glsl" +alias8 = "MASK_RESIZE" +filter_linear8 = "false" +scale_type_x8 = "viewport" +scale_x8 = "0.0625" +scale_type_y8 = "source" +scale_y8 = "1.0" +#srgb_framebuffer8 = "false" # mask_texture is already assumed linear + +# Pass9: Resample (misconverged) scanlines horizontally, apply halation, and +# apply the phosphor mask. +shader9 = "shaders/crt-royale/src/crt-royale-scanlines-horizontal-apply-mask.glsl" +alias9 = "MASKED_SCANLINES" +filter_linear9 = "true" # This could just as easily be nearest neighbor. +scale_type9 = "viewport" +scale9 = "1.0" +#float_framebuffer9 = "true" +srgb_framebuffer9 = "true" + +# Pass 10: Compute a brightpass. This will require reading the final mask. +shader10 = "shaders/crt-royale/src/crt-royale-brightpass.glsl" +alias10 = "BRIGHTPASS" +filter_linear10 = "true" # This could just as easily be nearest neighbor. +scale_type10 = "viewport" +scale10 = "1.0" +srgb_framebuffer10 = "true" + +# Pass 11: Blur the brightpass vertically +shader11 = "shaders/crt-royale/src/crt-royale-bloom-vertical.glsl" +filter_linear11 = "true" # This could just as easily be nearest neighbor. +scale_type11 = "source" +scale11 = "1.0" +srgb_framebuffer11 = "true" + +# Pass 12: Blur the brightpass horizontally and combine it with the dimpass: +shader12 = "shaders/crt-royale/src/crt-royale-bloom-horizontal-reconstitute.glsl" +filter_linear12 = "true" +scale_type12 = "source" +scale12 = "1.0" +srgb_framebuffer12 = "true" + +# Pass 13: Compute curvature/AA: +shader13 = "shaders/crt-royale/src/crt-royale-geometry-aa-last-pass.glsl" +filter_linear13 = "true" +scale_type13 = "viewport" +mipmap_input13 = "true" +texture_wrap_mode13 = "clamp_to_edge" + diff --git a/crt/crt-royale-ntsc-256px-svideo.glslp b/crt/crt-royale-ntsc-256px-svideo.glslp new file mode 100644 index 0000000..adde9cc --- /dev/null +++ b/crt/crt-royale-ntsc-256px-svideo.glslp @@ -0,0 +1,224 @@ +# IMPORTANT: +# Shader passes need to know details about the image in the mask_texture LUT +# files, so set the following constants in user-cgp-constants.h accordingly: +# 1.) mask_triads_per_tile = (number of horizontal triads in mask texture LUT's) +# 2.) mask_texture_small_size = (texture size of mask*texture_small LUT's) +# 3.) mask_texture_large_size = (texture size of mask*texture_large LUT's) +# 4.) mask_grille_avg_color = (avg. brightness of mask_grille_texture* LUT's, in [0, 1]) +# 5.) mask_slot_avg_color = (avg. brightness of mask_slot_texture* LUT's, in [0, 1]) +# 6.) mask_shadow_avg_color = (avg. brightness of mask_shadow_texture* LUT's, in [0, 1]) +# Shader passes also need to know certain scales set in this .glslp, but their +# compilation model doesn't currently allow the .glslp file to tell them. Make +# sure to set the following constants in user-cgp-constants.h accordingly too: +# 1.) bloom_approx_scale_x = scale_x2 +# 2.) mask_resize_viewport_scale = float2(scale_x6, scale_y5) +# Finally, shader passes need to know the value of geom_max_aspect_ratio used to +# calculate scale_y5 (among other values): +# 1.) geom_max_aspect_ratio = (geom_max_aspect_ratio used to calculate scale_y5) + +shaders = "14" + +# NTSC Shader Passes +shader0 = "../ntsc/shaders/ntsc-pass1-svideo-3phase.glsl" +shader1 = "../ntsc/shaders/ntsc-pass2-3phase.glsl" + +filter_linear0 = false +filter_linear1 = false + +scale_type_x0 = absolute +scale_type_y0 = source +scale_x0 = 1536 +scale_y0 = 1.0 +frame_count_mod0 = 2 +float_framebuffer0 = true + +scale_type1 = source +scale_x1 = 0.5 +scale_y1 = 1.0 + +# Set an identifier, filename, and sampling traits for the phosphor mask texture. +# Load an aperture grille, slot mask, and an EDP shadow mask, and load a small +# non-mipmapped version and a large mipmapped version. +# TODO: Test masks in other directories. +textures = "mask_grille_texture_small;mask_grille_texture_large;mask_slot_texture_small;mask_slot_texture_large;mask_shadow_texture_small;mask_shadow_texture_large" +mask_grille_texture_small = "shaders/crt-royale/TileableLinearApertureGrille15Wide8And5d5SpacingResizeTo64.png" +mask_grille_texture_large = "shaders/crt-royale/TileableLinearApertureGrille15Wide8And5d5Spacing.png" +mask_slot_texture_small = "shaders/crt-royale/TileableLinearSlotMaskTall15Wide9And4d5Horizontal9d14VerticalSpacingResizeTo64.png" +mask_slot_texture_large = "shaders/crt-royale/TileableLinearSlotMaskTall15Wide9And4d5Horizontal9d14VerticalSpacing.png" +mask_shadow_texture_small = "shaders/crt-royale/TileableLinearShadowMaskEDPResizeTo64.png" +mask_shadow_texture_large = "shaders/crt-royale/TileableLinearShadowMaskEDP.png" +mask_grille_texture_small_wrap_mode = "repeat" +mask_grille_texture_large_wrap_mode = "repeat" +mask_slot_texture_small_wrap_mode = "repeat" +mask_slot_texture_large_wrap_mode = "repeat" +mask_shadow_texture_small_wrap_mode = "repeat" +mask_shadow_texture_large_wrap_mode = "repeat" +mask_grille_texture_small_linear = "true" +mask_grille_texture_large_linear = "true" +mask_slot_texture_small_linear = "true" +mask_slot_texture_large_linear = "true" +mask_shadow_texture_small_linear = "true" +mask_shadow_texture_large_linear = "true" +mask_grille_texture_small_mipmap = "false" # Mipmapping causes artifacts with manually resized masks without tex2Dlod +mask_grille_texture_large_mipmap = "true" # Essential for hardware-resized masks +mask_slot_texture_small_mipmap = "false" # Mipmapping causes artifacts with manually resized masks without tex2Dlod +mask_slot_texture_large_mipmap = "true" # Essential for hardware-resized masks +mask_shadow_texture_small_mipmap = "false" # Mipmapping causes artifacts with manually resized masks without tex2Dlod +mask_shadow_texture_large_mipmap = "true" # Essential for hardware-resized masks + + +# Pass2: Linearize the input based on CRT gamma and bob interlaced fields. +# (Bobbing ensures we can immediately blur without getting artifacts.) +shader2 = "shaders/crt-royale/src/crt-royale-first-pass-linearize-crt-gamma-bob-fields.glsl" +alias2 = "ORIG_LINEARIZED" +filter_linear2 = "false" +scale_type2 = "source" +scale2 = "1.0" +srgb_framebuffer2 = "true" + +# Pass3: Resample interlaced (and misconverged) scanlines vertically. +# Separating vertical/horizontal scanline sampling is faster: It lets us +# consider more scanlines while calculating weights for fewer pixels, and +# it reduces our samples from vertical*horizontal to vertical+horizontal. +# This has to come right after ORIG_LINEARIZED, because there's no +# "original_source" scale_type we can use later. +shader3 = "shaders/crt-royale/src/crt-royale-scanlines-vertical-interlacing.glsl" +alias3 = "VERTICAL_SCANLINES" +filter_linear3 = "true" +scale_type_x3 = "source" +scale_x3 = "1.0" +scale_type_y3 = "viewport" +scale_y3 = "1.0" +#float_framebuffer3 = "true" +srgb_framebuffer3 = "true" + +# Pass4: Do a small resize blur of ORIG_LINEARIZED at an absolute size, and +# account for convergence offsets. We want to blur a predictable portion of the +# screen to match the phosphor bloom, and absolute scale works best for +# reliable results with a fixed-size bloom. Picking a scale is tricky: +# a.) 400x300 is a good compromise for the "fake-bloom" version: It's low enough +# to blur high-res/interlaced sources but high enough that resampling +# doesn't smear low-res sources too much. +# b.) 320x240 works well for the "real bloom" version: It's 1-1.5% faster, and +# the only noticeable visual difference is a larger halation spread (which +# may be a good thing for people who like to crank it up). +# Note the 4:3 aspect ratio assumes the input has cropped geom_overscan (so it's +# *intended* for an ~4:3 aspect ratio). +shader4 = "shaders/crt-royale/src/crt-royale-bloom-approx.glsl" +alias4 = "BLOOM_APPROX" +filter_linear4 = "true" +scale_type4 = "absolute" +scale_x4 = "320" +scale_y4 = "240" +srgb_framebuffer4 = "true" + +# Pass5: Vertically blur the input for halation and refractive diffusion. +# Base this on BLOOM_APPROX: This blur should be small and fast, and blurring +# a constant portion of the screen is probably physically correct if the +# viewport resolution is proportional to the simulated CRT size. +shader5 = "../blurs/shaders/royale/blur9fast-vertical.glsl" +filter_linear5 = "true" +scale_type5 = "source" +scale5 = "1.0" +srgb_framebuffer5 = "true" + +# Pass6: Horizontally blur the input for halation and refractive diffusion. +# Note: Using a one-pass 9x9 blur is about 1% slower. +shader6 = "../blurs/shaders/royale/blur9fast-horizontal.glsl" +alias6 = "HALATION_BLUR" +filter_linear6 = "true" +scale_type6 = "source" +scale6 = "1.0" +srgb_framebuffer6 = "true" + +# Pass7: Lanczos-resize the phosphor mask vertically. Set the absolute +# scale_x7 == mask_texture_small_size.x (see IMPORTANT above). Larger scales +# will blur, and smaller scales could get nasty. The vertical size must be +# based on the viewport size and calculated carefully to avoid artifacts later. +# First calculate the minimum number of mask tiles we need to draw. +# Since curvature is computed after the scanline masking pass: +# num_resized_mask_tiles = 2.0; +# If curvature were computed in the scanline masking pass (it's not): +# max_mask_texel_border = ~3.0 * (1/3.0 + 4.0*sqrt(2.0) + 0.5 + 1.0); +# max_mask_tile_border = max_mask_texel_border/ +# (min_resized_phosphor_triad_size * mask_triads_per_tile); +# num_resized_mask_tiles = max(2.0, 1.0 + max_mask_tile_border * 2.0); +# At typical values (triad_size >= 2.0, mask_triads_per_tile == 8): +# num_resized_mask_tiles = ~3.8 +# Triad sizes are given in horizontal terms, so we need geom_max_aspect_ratio +# to relate them to vertical resolution. The widest we expect is: +# geom_max_aspect_ratio = 4.0/3.0 # Note: Shader passes need to know this! +# The fewer triads we tile across the screen, the larger each triad will be as a +# fraction of the viewport size, and the larger scale_y5 must be to draw a full +# num_resized_mask_tiles. Therefore, we must decide the smallest number of +# triads we'll guarantee can be displayed on screen. We'll set this according +# to 3-pixel triads at 768p resolution (the lowest anyone's likely to use): +# min_allowed_viewport_triads = 768.0*geom_max_aspect_ratio / 3.0 = 341.333333 +# Now calculate the viewport scale that ensures we can draw resized_mask_tiles: +# min_scale_x = resized_mask_tiles * mask_triads_per_tile / +# min_allowed_viewport_triads +# scale_y7 = geom_max_aspect_ratio * min_scale_x +# # Some code might depend on equal scales: +# scale_x8 = scale_y7 +# Given our default geom_max_aspect_ratio and min_allowed_viewport_triads: +# scale_y7 = 4.0/3.0 * 2.0/(341.33333 / 8.0) = 0.0625 +# IMPORTANT: The scales MUST be calculated in this way. If you wish to change +# geom_max_aspect_ratio, update that constant in user-cgp-constants.h! +shader7 = "shaders/crt-royale/src/crt-royale-mask-resize-vertical.glsl" +filter_linear7 = "true" +scale_type_x7 = "absolute" +scale_x7 = "64" +scale_type_y7 = "viewport" +scale_y7 = "0.0625" # Safe for >= 341.333 horizontal triads at viewport size +#srgb_framebuffer7 = "false" # mask_texture is already assumed linear + +# Pass8: Lanczos-resize the phosphor mask horizontally. scale_x8 = scale_y7. +# TODO: Check again if the shaders actually require equal scales. +shader8 = "shaders/crt-royale/src/crt-royale-mask-resize-horizontal.glsl" +alias8 = "MASK_RESIZE" +filter_linear8 = "false" +scale_type_x8 = "viewport" +scale_x8 = "0.0625" +scale_type_y8 = "source" +scale_y8 = "1.0" +#srgb_framebuffer8 = "false" # mask_texture is already assumed linear + +# Pass9: Resample (misconverged) scanlines horizontally, apply halation, and +# apply the phosphor mask. +shader9 = "shaders/crt-royale/src/crt-royale-scanlines-horizontal-apply-mask.glsl" +alias9 = "MASKED_SCANLINES" +filter_linear9 = "true" # This could just as easily be nearest neighbor. +scale_type9 = "viewport" +scale9 = "1.0" +#float_framebuffer9 = "true" +srgb_framebuffer9 = "true" + +# Pass 10: Compute a brightpass. This will require reading the final mask. +shader10 = "shaders/crt-royale/src/crt-royale-brightpass.glsl" +alias10 = "BRIGHTPASS" +filter_linear10 = "true" # This could just as easily be nearest neighbor. +scale_type10 = "viewport" +scale10 = "1.0" +srgb_framebuffer10 = "true" + +# Pass 11: Blur the brightpass vertically +shader11 = "shaders/crt-royale/src/crt-royale-bloom-vertical.glsl" +filter_linear11 = "true" # This could just as easily be nearest neighbor. +scale_type11 = "source" +scale11 = "1.0" +srgb_framebuffer11 = "true" + +# Pass 12: Blur the brightpass horizontally and combine it with the dimpass: +shader12 = "shaders/crt-royale/src/crt-royale-bloom-horizontal-reconstitute.glsl" +filter_linear12 = "true" +scale_type12 = "source" +scale12 = "1.0" +srgb_framebuffer12 = "true" + +# Pass 13: Compute curvature/AA: +shader13 = "shaders/crt-royale/src/crt-royale-geometry-aa-last-pass.glsl" +filter_linear13 = "true" +scale_type13 = "viewport" +mipmap_input13 = "true" +texture_wrap_mode13 = "clamp_to_edge" + diff --git a/crt/crt-royale-ntsc-320px-composite.glslp b/crt/crt-royale-ntsc-320px-composite.glslp new file mode 100644 index 0000000..12dbf59 --- /dev/null +++ b/crt/crt-royale-ntsc-320px-composite.glslp @@ -0,0 +1,224 @@ +# IMPORTANT: +# Shader passes need to know details about the image in the mask_texture LUT +# files, so set the following constants in user-cgp-constants.h accordingly: +# 1.) mask_triads_per_tile = (number of horizontal triads in mask texture LUT's) +# 2.) mask_texture_small_size = (texture size of mask*texture_small LUT's) +# 3.) mask_texture_large_size = (texture size of mask*texture_large LUT's) +# 4.) mask_grille_avg_color = (avg. brightness of mask_grille_texture* LUT's, in [0, 1]) +# 5.) mask_slot_avg_color = (avg. brightness of mask_slot_texture* LUT's, in [0, 1]) +# 6.) mask_shadow_avg_color = (avg. brightness of mask_shadow_texture* LUT's, in [0, 1]) +# Shader passes also need to know certain scales set in this .glslp, but their +# compilation model doesn't currently allow the .glslp file to tell them. Make +# sure to set the following constants in user-cgp-constants.h accordingly too: +# 1.) bloom_approx_scale_x = scale_x2 +# 2.) mask_resize_viewport_scale = float2(scale_x6, scale_y5) +# Finally, shader passes need to know the value of geom_max_aspect_ratio used to +# calculate scale_y5 (among other values): +# 1.) geom_max_aspect_ratio = (geom_max_aspect_ratio used to calculate scale_y5) + +shaders = "14" + +# NTSC Shader Passes +shader0 = "../ntsc/shaders/ntsc-pass1-composite-2phase.glsl" +shader1 = "../ntsc/shaders/ntsc-pass2-2phase.glsl" + +filter_linear0 = false +filter_linear1 = false + +scale_type_x0 = absolute +scale_type_y0 = source +scale_x0 = 1280 +scale_y0 = 1.0 +frame_count_mod0 = 2 +float_framebuffer0 = true + +scale_type1 = source +scale_x1 = 0.5 +scale_y1 = 1.0 + +# Set an identifier, filename, and sampling traits for the phosphor mask texture. +# Load an aperture grille, slot mask, and an EDP shadow mask, and load a small +# non-mipmapped version and a large mipmapped version. +# TODO: Test masks in other directories. +textures = "mask_grille_texture_small;mask_grille_texture_large;mask_slot_texture_small;mask_slot_texture_large;mask_shadow_texture_small;mask_shadow_texture_large" +mask_grille_texture_small = "shaders/crt-royale/TileableLinearApertureGrille15Wide8And5d5SpacingResizeTo64.png" +mask_grille_texture_large = "shaders/crt-royale/TileableLinearApertureGrille15Wide8And5d5Spacing.png" +mask_slot_texture_small = "shaders/crt-royale/TileableLinearSlotMaskTall15Wide9And4d5Horizontal9d14VerticalSpacingResizeTo64.png" +mask_slot_texture_large = "shaders/crt-royale/TileableLinearSlotMaskTall15Wide9And4d5Horizontal9d14VerticalSpacing.png" +mask_shadow_texture_small = "shaders/crt-royale/TileableLinearShadowMaskEDPResizeTo64.png" +mask_shadow_texture_large = "shaders/crt-royale/TileableLinearShadowMaskEDP.png" +mask_grille_texture_small_wrap_mode = "repeat" +mask_grille_texture_large_wrap_mode = "repeat" +mask_slot_texture_small_wrap_mode = "repeat" +mask_slot_texture_large_wrap_mode = "repeat" +mask_shadow_texture_small_wrap_mode = "repeat" +mask_shadow_texture_large_wrap_mode = "repeat" +mask_grille_texture_small_linear = "true" +mask_grille_texture_large_linear = "true" +mask_slot_texture_small_linear = "true" +mask_slot_texture_large_linear = "true" +mask_shadow_texture_small_linear = "true" +mask_shadow_texture_large_linear = "true" +mask_grille_texture_small_mipmap = "false" # Mipmapping causes artifacts with manually resized masks without tex2Dlod +mask_grille_texture_large_mipmap = "true" # Essential for hardware-resized masks +mask_slot_texture_small_mipmap = "false" # Mipmapping causes artifacts with manually resized masks without tex2Dlod +mask_slot_texture_large_mipmap = "true" # Essential for hardware-resized masks +mask_shadow_texture_small_mipmap = "false" # Mipmapping causes artifacts with manually resized masks without tex2Dlod +mask_shadow_texture_large_mipmap = "true" # Essential for hardware-resized masks + + +# Pass2: Linearize the input based on CRT gamma and bob interlaced fields. +# (Bobbing ensures we can immediately blur without getting artifacts.) +shader2 = "shaders/crt-royale/src/crt-royale-first-pass-linearize-crt-gamma-bob-fields.glsl" +alias2 = "ORIG_LINEARIZED" +filter_linear2 = "false" +scale_type2 = "source" +scale2 = "1.0" +srgb_framebuffer2 = "true" + +# Pass3: Resample interlaced (and misconverged) scanlines vertically. +# Separating vertical/horizontal scanline sampling is faster: It lets us +# consider more scanlines while calculating weights for fewer pixels, and +# it reduces our samples from vertical*horizontal to vertical+horizontal. +# This has to come right after ORIG_LINEARIZED, because there's no +# "original_source" scale_type we can use later. +shader3 = "shaders/crt-royale/src/crt-royale-scanlines-vertical-interlacing.glsl" +alias3 = "VERTICAL_SCANLINES" +filter_linear3 = "true" +scale_type_x3 = "source" +scale_x3 = "1.0" +scale_type_y3 = "viewport" +scale_y3 = "1.0" +#float_framebuffer3 = "true" +srgb_framebuffer3 = "true" + +# Pass4: Do a small resize blur of ORIG_LINEARIZED at an absolute size, and +# account for convergence offsets. We want to blur a predictable portion of the +# screen to match the phosphor bloom, and absolute scale works best for +# reliable results with a fixed-size bloom. Picking a scale is tricky: +# a.) 400x300 is a good compromise for the "fake-bloom" version: It's low enough +# to blur high-res/interlaced sources but high enough that resampling +# doesn't smear low-res sources too much. +# b.) 320x240 works well for the "real bloom" version: It's 1-1.5% faster, and +# the only noticeable visual difference is a larger halation spread (which +# may be a good thing for people who like to crank it up). +# Note the 4:3 aspect ratio assumes the input has cropped geom_overscan (so it's +# *intended* for an ~4:3 aspect ratio). +shader4 = "shaders/crt-royale/src/crt-royale-bloom-approx.glsl" +alias4 = "BLOOM_APPROX" +filter_linear4 = "true" +scale_type4 = "absolute" +scale_x4 = "320" +scale_y4 = "240" +srgb_framebuffer4 = "true" + +# Pass5: Vertically blur the input for halation and refractive diffusion. +# Base this on BLOOM_APPROX: This blur should be small and fast, and blurring +# a constant portion of the screen is probably physically correct if the +# viewport resolution is proportional to the simulated CRT size. +shader5 = "../blurs/shaders/royale/blur9fast-vertical.glsl" +filter_linear5 = "true" +scale_type5 = "source" +scale5 = "1.0" +srgb_framebuffer5 = "true" + +# Pass6: Horizontally blur the input for halation and refractive diffusion. +# Note: Using a one-pass 9x9 blur is about 1% slower. +shader6 = "../blurs/shaders/royale/blur9fast-horizontal.glsl" +alias6 = "HALATION_BLUR" +filter_linear6 = "true" +scale_type6 = "source" +scale6 = "1.0" +srgb_framebuffer6 = "true" + +# Pass7: Lanczos-resize the phosphor mask vertically. Set the absolute +# scale_x7 == mask_texture_small_size.x (see IMPORTANT above). Larger scales +# will blur, and smaller scales could get nasty. The vertical size must be +# based on the viewport size and calculated carefully to avoid artifacts later. +# First calculate the minimum number of mask tiles we need to draw. +# Since curvature is computed after the scanline masking pass: +# num_resized_mask_tiles = 2.0; +# If curvature were computed in the scanline masking pass (it's not): +# max_mask_texel_border = ~3.0 * (1/3.0 + 4.0*sqrt(2.0) + 0.5 + 1.0); +# max_mask_tile_border = max_mask_texel_border/ +# (min_resized_phosphor_triad_size * mask_triads_per_tile); +# num_resized_mask_tiles = max(2.0, 1.0 + max_mask_tile_border * 2.0); +# At typical values (triad_size >= 2.0, mask_triads_per_tile == 8): +# num_resized_mask_tiles = ~3.8 +# Triad sizes are given in horizontal terms, so we need geom_max_aspect_ratio +# to relate them to vertical resolution. The widest we expect is: +# geom_max_aspect_ratio = 4.0/3.0 # Note: Shader passes need to know this! +# The fewer triads we tile across the screen, the larger each triad will be as a +# fraction of the viewport size, and the larger scale_y5 must be to draw a full +# num_resized_mask_tiles. Therefore, we must decide the smallest number of +# triads we'll guarantee can be displayed on screen. We'll set this according +# to 3-pixel triads at 768p resolution (the lowest anyone's likely to use): +# min_allowed_viewport_triads = 768.0*geom_max_aspect_ratio / 3.0 = 341.333333 +# Now calculate the viewport scale that ensures we can draw resized_mask_tiles: +# min_scale_x = resized_mask_tiles * mask_triads_per_tile / +# min_allowed_viewport_triads +# scale_y7 = geom_max_aspect_ratio * min_scale_x +# # Some code might depend on equal scales: +# scale_x8 = scale_y7 +# Given our default geom_max_aspect_ratio and min_allowed_viewport_triads: +# scale_y7 = 4.0/3.0 * 2.0/(341.33333 / 8.0) = 0.0625 +# IMPORTANT: The scales MUST be calculated in this way. If you wish to change +# geom_max_aspect_ratio, update that constant in user-cgp-constants.h! +shader7 = "shaders/crt-royale/src/crt-royale-mask-resize-vertical.glsl" +filter_linear7 = "true" +scale_type_x7 = "absolute" +scale_x7 = "64" +scale_type_y7 = "viewport" +scale_y7 = "0.0625" # Safe for >= 341.333 horizontal triads at viewport size +#srgb_framebuffer7 = "false" # mask_texture is already assumed linear + +# Pass8: Lanczos-resize the phosphor mask horizontally. scale_x8 = scale_y7. +# TODO: Check again if the shaders actually require equal scales. +shader8 = "shaders/crt-royale/src/crt-royale-mask-resize-horizontal.glsl" +alias8 = "MASK_RESIZE" +filter_linear8 = "false" +scale_type_x8 = "viewport" +scale_x8 = "0.0625" +scale_type_y8 = "source" +scale_y8 = "1.0" +#srgb_framebuffer8 = "false" # mask_texture is already assumed linear + +# Pass9: Resample (misconverged) scanlines horizontally, apply halation, and +# apply the phosphor mask. +shader9 = "shaders/crt-royale/src/crt-royale-scanlines-horizontal-apply-mask.glsl" +alias9 = "MASKED_SCANLINES" +filter_linear9 = "true" # This could just as easily be nearest neighbor. +scale_type9 = "viewport" +scale9 = "1.0" +#float_framebuffer9 = "true" +srgb_framebuffer9 = "true" + +# Pass 10: Compute a brightpass. This will require reading the final mask. +shader10 = "shaders/crt-royale/src/crt-royale-brightpass.glsl" +alias10 = "BRIGHTPASS" +filter_linear10 = "true" # This could just as easily be nearest neighbor. +scale_type10 = "viewport" +scale10 = "1.0" +srgb_framebuffer10 = "true" + +# Pass 11: Blur the brightpass vertically +shader11 = "shaders/crt-royale/src/crt-royale-bloom-vertical.glsl" +filter_linear11 = "true" # This could just as easily be nearest neighbor. +scale_type11 = "source" +scale11 = "1.0" +srgb_framebuffer11 = "true" + +# Pass 12: Blur the brightpass horizontally and combine it with the dimpass: +shader12 = "shaders/crt-royale/src/crt-royale-bloom-horizontal-reconstitute.glsl" +filter_linear12 = "true" +scale_type12 = "source" +scale12 = "1.0" +srgb_framebuffer12 = "true" + +# Pass 13: Compute curvature/AA: +shader13 = "shaders/crt-royale/src/crt-royale-geometry-aa-last-pass.glsl" +filter_linear13 = "true" +scale_type13 = "viewport" +mipmap_input13 = "true" +texture_wrap_mode13 = "clamp_to_edge" + diff --git a/crt/crt-royale-ntsc-320px-svideo.glslp b/crt/crt-royale-ntsc-320px-svideo.glslp new file mode 100644 index 0000000..701cdea --- /dev/null +++ b/crt/crt-royale-ntsc-320px-svideo.glslp @@ -0,0 +1,224 @@ +# IMPORTANT: +# Shader passes need to know details about the image in the mask_texture LUT +# files, so set the following constants in user-cgp-constants.h accordingly: +# 1.) mask_triads_per_tile = (number of horizontal triads in mask texture LUT's) +# 2.) mask_texture_small_size = (texture size of mask*texture_small LUT's) +# 3.) mask_texture_large_size = (texture size of mask*texture_large LUT's) +# 4.) mask_grille_avg_color = (avg. brightness of mask_grille_texture* LUT's, in [0, 1]) +# 5.) mask_slot_avg_color = (avg. brightness of mask_slot_texture* LUT's, in [0, 1]) +# 6.) mask_shadow_avg_color = (avg. brightness of mask_shadow_texture* LUT's, in [0, 1]) +# Shader passes also need to know certain scales set in this .glslp, but their +# compilation model doesn't currently allow the .glslp file to tell them. Make +# sure to set the following constants in user-cgp-constants.h accordingly too: +# 1.) bloom_approx_scale_x = scale_x2 +# 2.) mask_resize_viewport_scale = float2(scale_x6, scale_y5) +# Finally, shader passes need to know the value of geom_max_aspect_ratio used to +# calculate scale_y5 (among other values): +# 1.) geom_max_aspect_ratio = (geom_max_aspect_ratio used to calculate scale_y5) + +shaders = "14" + +# NTSC Shader Passes +shader0 = "../ntsc/shaders/ntsc-pass1-svideo-2phase.glsl" +shader1 = "../ntsc/shaders/ntsc-pass2-2phase.glsl" + +filter_linear0 = false +filter_linear1 = false + +scale_type_x0 = absolute +scale_type_y0 = source +scale_x0 = 1920 +scale_y0 = 1.0 +frame_count_mod0 = 2 +float_framebuffer0 = true + +scale_type1 = source +scale_x1 = 0.5 +scale_y1 = 1.0 + +# Set an identifier, filename, and sampling traits for the phosphor mask texture. +# Load an aperture grille, slot mask, and an EDP shadow mask, and load a small +# non-mipmapped version and a large mipmapped version. +# TODO: Test masks in other directories. +textures = "mask_grille_texture_small;mask_grille_texture_large;mask_slot_texture_small;mask_slot_texture_large;mask_shadow_texture_small;mask_shadow_texture_large" +mask_grille_texture_small = "shaders/crt-royale/TileableLinearApertureGrille15Wide8And5d5SpacingResizeTo64.png" +mask_grille_texture_large = "shaders/crt-royale/TileableLinearApertureGrille15Wide8And5d5Spacing.png" +mask_slot_texture_small = "shaders/crt-royale/TileableLinearSlotMaskTall15Wide9And4d5Horizontal9d14VerticalSpacingResizeTo64.png" +mask_slot_texture_large = "shaders/crt-royale/TileableLinearSlotMaskTall15Wide9And4d5Horizontal9d14VerticalSpacing.png" +mask_shadow_texture_small = "shaders/crt-royale/TileableLinearShadowMaskEDPResizeTo64.png" +mask_shadow_texture_large = "shaders/crt-royale/TileableLinearShadowMaskEDP.png" +mask_grille_texture_small_wrap_mode = "repeat" +mask_grille_texture_large_wrap_mode = "repeat" +mask_slot_texture_small_wrap_mode = "repeat" +mask_slot_texture_large_wrap_mode = "repeat" +mask_shadow_texture_small_wrap_mode = "repeat" +mask_shadow_texture_large_wrap_mode = "repeat" +mask_grille_texture_small_linear = "true" +mask_grille_texture_large_linear = "true" +mask_slot_texture_small_linear = "true" +mask_slot_texture_large_linear = "true" +mask_shadow_texture_small_linear = "true" +mask_shadow_texture_large_linear = "true" +mask_grille_texture_small_mipmap = "false" # Mipmapping causes artifacts with manually resized masks without tex2Dlod +mask_grille_texture_large_mipmap = "true" # Essential for hardware-resized masks +mask_slot_texture_small_mipmap = "false" # Mipmapping causes artifacts with manually resized masks without tex2Dlod +mask_slot_texture_large_mipmap = "true" # Essential for hardware-resized masks +mask_shadow_texture_small_mipmap = "false" # Mipmapping causes artifacts with manually resized masks without tex2Dlod +mask_shadow_texture_large_mipmap = "true" # Essential for hardware-resized masks + + +# Pass2: Linearize the input based on CRT gamma and bob interlaced fields. +# (Bobbing ensures we can immediately blur without getting artifacts.) +shader2 = "shaders/crt-royale/src/crt-royale-first-pass-linearize-crt-gamma-bob-fields.glsl" +alias2 = "ORIG_LINEARIZED" +filter_linear2 = "false" +scale_type2 = "source" +scale2 = "1.0" +srgb_framebuffer2 = "true" + +# Pass3: Resample interlaced (and misconverged) scanlines vertically. +# Separating vertical/horizontal scanline sampling is faster: It lets us +# consider more scanlines while calculating weights for fewer pixels, and +# it reduces our samples from vertical*horizontal to vertical+horizontal. +# This has to come right after ORIG_LINEARIZED, because there's no +# "original_source" scale_type we can use later. +shader3 = "shaders/crt-royale/src/crt-royale-scanlines-vertical-interlacing.glsl" +alias3 = "VERTICAL_SCANLINES" +filter_linear3 = "true" +scale_type_x3 = "source" +scale_x3 = "1.0" +scale_type_y3 = "viewport" +scale_y3 = "1.0" +#float_framebuffer3 = "true" +srgb_framebuffer3 = "true" + +# Pass4: Do a small resize blur of ORIG_LINEARIZED at an absolute size, and +# account for convergence offsets. We want to blur a predictable portion of the +# screen to match the phosphor bloom, and absolute scale works best for +# reliable results with a fixed-size bloom. Picking a scale is tricky: +# a.) 400x300 is a good compromise for the "fake-bloom" version: It's low enough +# to blur high-res/interlaced sources but high enough that resampling +# doesn't smear low-res sources too much. +# b.) 320x240 works well for the "real bloom" version: It's 1-1.5% faster, and +# the only noticeable visual difference is a larger halation spread (which +# may be a good thing for people who like to crank it up). +# Note the 4:3 aspect ratio assumes the input has cropped geom_overscan (so it's +# *intended* for an ~4:3 aspect ratio). +shader4 = "shaders/crt-royale/src/crt-royale-bloom-approx.glsl" +alias4 = "BLOOM_APPROX" +filter_linear4 = "true" +scale_type4 = "absolute" +scale_x4 = "320" +scale_y4 = "240" +srgb_framebuffer4 = "true" + +# Pass5: Vertically blur the input for halation and refractive diffusion. +# Base this on BLOOM_APPROX: This blur should be small and fast, and blurring +# a constant portion of the screen is probably physically correct if the +# viewport resolution is proportional to the simulated CRT size. +shader5 = "../blurs/shaders/royale/blur9fast-vertical.glsl" +filter_linear5 = "true" +scale_type5 = "source" +scale5 = "1.0" +srgb_framebuffer5 = "true" + +# Pass6: Horizontally blur the input for halation and refractive diffusion. +# Note: Using a one-pass 9x9 blur is about 1% slower. +shader6 = "../blurs/shaders/royale/blur9fast-horizontal.glsl" +alias6 = "HALATION_BLUR" +filter_linear6 = "true" +scale_type6 = "source" +scale6 = "1.0" +srgb_framebuffer6 = "true" + +# Pass7: Lanczos-resize the phosphor mask vertically. Set the absolute +# scale_x7 == mask_texture_small_size.x (see IMPORTANT above). Larger scales +# will blur, and smaller scales could get nasty. The vertical size must be +# based on the viewport size and calculated carefully to avoid artifacts later. +# First calculate the minimum number of mask tiles we need to draw. +# Since curvature is computed after the scanline masking pass: +# num_resized_mask_tiles = 2.0; +# If curvature were computed in the scanline masking pass (it's not): +# max_mask_texel_border = ~3.0 * (1/3.0 + 4.0*sqrt(2.0) + 0.5 + 1.0); +# max_mask_tile_border = max_mask_texel_border/ +# (min_resized_phosphor_triad_size * mask_triads_per_tile); +# num_resized_mask_tiles = max(2.0, 1.0 + max_mask_tile_border * 2.0); +# At typical values (triad_size >= 2.0, mask_triads_per_tile == 8): +# num_resized_mask_tiles = ~3.8 +# Triad sizes are given in horizontal terms, so we need geom_max_aspect_ratio +# to relate them to vertical resolution. The widest we expect is: +# geom_max_aspect_ratio = 4.0/3.0 # Note: Shader passes need to know this! +# The fewer triads we tile across the screen, the larger each triad will be as a +# fraction of the viewport size, and the larger scale_y5 must be to draw a full +# num_resized_mask_tiles. Therefore, we must decide the smallest number of +# triads we'll guarantee can be displayed on screen. We'll set this according +# to 3-pixel triads at 768p resolution (the lowest anyone's likely to use): +# min_allowed_viewport_triads = 768.0*geom_max_aspect_ratio / 3.0 = 341.333333 +# Now calculate the viewport scale that ensures we can draw resized_mask_tiles: +# min_scale_x = resized_mask_tiles * mask_triads_per_tile / +# min_allowed_viewport_triads +# scale_y7 = geom_max_aspect_ratio * min_scale_x +# # Some code might depend on equal scales: +# scale_x8 = scale_y7 +# Given our default geom_max_aspect_ratio and min_allowed_viewport_triads: +# scale_y7 = 4.0/3.0 * 2.0/(341.33333 / 8.0) = 0.0625 +# IMPORTANT: The scales MUST be calculated in this way. If you wish to change +# geom_max_aspect_ratio, update that constant in user-cgp-constants.h! +shader7 = "shaders/crt-royale/src/crt-royale-mask-resize-vertical.glsl" +filter_linear7 = "true" +scale_type_x7 = "absolute" +scale_x7 = "64" +scale_type_y7 = "viewport" +scale_y7 = "0.0625" # Safe for >= 341.333 horizontal triads at viewport size +#srgb_framebuffer7 = "false" # mask_texture is already assumed linear + +# Pass8: Lanczos-resize the phosphor mask horizontally. scale_x8 = scale_y7. +# TODO: Check again if the shaders actually require equal scales. +shader8 = "shaders/crt-royale/src/crt-royale-mask-resize-horizontal.glsl" +alias8 = "MASK_RESIZE" +filter_linear8 = "false" +scale_type_x8 = "viewport" +scale_x8 = "0.0625" +scale_type_y8 = "source" +scale_y8 = "1.0" +#srgb_framebuffer8 = "false" # mask_texture is already assumed linear + +# Pass9: Resample (misconverged) scanlines horizontally, apply halation, and +# apply the phosphor mask. +shader9 = "shaders/crt-royale/src/crt-royale-scanlines-horizontal-apply-mask.glsl" +alias9 = "MASKED_SCANLINES" +filter_linear9 = "true" # This could just as easily be nearest neighbor. +scale_type9 = "viewport" +scale9 = "1.0" +#float_framebuffer9 = "true" +srgb_framebuffer9 = "true" + +# Pass 10: Compute a brightpass. This will require reading the final mask. +shader10 = "shaders/crt-royale/src/crt-royale-brightpass.glsl" +alias10 = "BRIGHTPASS" +filter_linear10 = "true" # This could just as easily be nearest neighbor. +scale_type10 = "viewport" +scale10 = "1.0" +srgb_framebuffer10 = "true" + +# Pass 11: Blur the brightpass vertically +shader11 = "shaders/crt-royale/src/crt-royale-bloom-vertical.glsl" +filter_linear11 = "true" # This could just as easily be nearest neighbor. +scale_type11 = "source" +scale11 = "1.0" +srgb_framebuffer11 = "true" + +# Pass 12: Blur the brightpass horizontally and combine it with the dimpass: +shader12 = "shaders/crt-royale/src/crt-royale-bloom-horizontal-reconstitute.glsl" +filter_linear12 = "true" +scale_type12 = "source" +scale12 = "1.0" +srgb_framebuffer12 = "true" + +# Pass 13: Compute curvature/AA: +shader13 = "shaders/crt-royale/src/crt-royale-geometry-aa-last-pass.glsl" +filter_linear13 = "true" +scale_type13 = "viewport" +mipmap_input13 = "true" +texture_wrap_mode13 = "clamp_to_edge" + diff --git a/crt/crt-royale-pal-r57shell.glslp b/crt/crt-royale-pal-r57shell.glslp new file mode 100644 index 0000000..1e95148 --- /dev/null +++ b/crt/crt-royale-pal-r57shell.glslp @@ -0,0 +1,219 @@ +# IMPORTANT: +# Shader passes need to know details about the image in the mask_texture LUT +# files, so set the following constants in user-cgp-constants.h accordingly: +# 1.) mask_triads_per_tile = (number of horizontal triads in mask texture LUT's) +# 2.) mask_texture_small_size = (texture size of mask*texture_small LUT's) +# 3.) mask_texture_large_size = (texture size of mask*texture_large LUT's) +# 4.) mask_grille_avg_color = (avg. brightness of mask_grille_texture* LUT's, in [0, 1]) +# 5.) mask_slot_avg_color = (avg. brightness of mask_slot_texture* LUT's, in [0, 1]) +# 6.) mask_shadow_avg_color = (avg. brightness of mask_shadow_texture* LUT's, in [0, 1]) +# Shader passes also need to know certain scales set in this .glslp, but their +# compilation model doesn't currently allow the .glslp file to tell them. Make +# sure to set the following constants in user-cgp-constants.h accordingly too: +# 1.) bloom_approx_scale_x = scale_x3 +# 2.) mask_resize_viewport_scale = float2(scale_x7, scale_y6) +# Finally, shader passes need to know the value of geom_max_aspect_ratio used to +# calculate scale_y5 (among other values): +# 1.) geom_max_aspect_ratio = (geom_max_aspect_ratio used to calculate scale_y5) + +shaders = "13" + +shader0 = "../pal/shaders/pal-r57shell.glsl" + +nes_lut = "../pal/resources/nes_lut.png" +nes_lut_linear = "false" +nes_lut_wrap_mode = "repeat" +nes_lut_mipmap = "false" + +filter_linear0 = false +scale_type_x0 = absolute +scale_type_y0 = source +scale_x0 = 1024 +scale_y0 = 1.0 +frame_count_mod0 = 2 + +# Set an identifier, filename, and sampling traits for the phosphor mask texture. +# Load an aperture grille, slot mask, and an EDP shadow mask, and load a small +# non-mipmapped version and a large mipmapped version. +# TODO: Test masks in other directories. +textures = "nes_lut;mask_grille_texture_small;mask_grille_texture_large;mask_slot_texture_small;mask_slot_texture_large;mask_shadow_texture_small;mask_shadow_texture_large" +mask_grille_texture_small = "shaders/crt-royale/TileableLinearApertureGrille15Wide8And5d5SpacingResizeTo64.png" +mask_grille_texture_large = "shaders/crt-royale/TileableLinearApertureGrille15Wide8And5d5Spacing.png" +mask_slot_texture_small = "shaders/crt-royale/TileableLinearSlotMaskTall15Wide9And4d5Horizontal9d14VerticalSpacingResizeTo64.png" +mask_slot_texture_large = "shaders/crt-royale/TileableLinearSlotMaskTall15Wide9And4d5Horizontal9d14VerticalSpacing.png" +mask_shadow_texture_small = "shaders/crt-royale/TileableLinearShadowMaskEDPResizeTo64.png" +mask_shadow_texture_large = "shaders/crt-royale/TileableLinearShadowMaskEDP.png" +mask_grille_texture_small_wrap_mode = "repeat" +mask_grille_texture_large_wrap_mode = "repeat" +mask_slot_texture_small_wrap_mode = "repeat" +mask_slot_texture_large_wrap_mode = "repeat" +mask_shadow_texture_small_wrap_mode = "repeat" +mask_shadow_texture_large_wrap_mode = "repeat" +mask_grille_texture_small_linear = "true" +mask_grille_texture_large_linear = "true" +mask_slot_texture_small_linear = "true" +mask_slot_texture_large_linear = "true" +mask_shadow_texture_small_linear = "true" +mask_shadow_texture_large_linear = "true" +mask_grille_texture_small_mipmap = "false" # Mipmapping causes artifacts with manually resized masks without tex2Dlod +mask_grille_texture_large_mipmap = "true" # Essential for hardware-resized masks +mask_slot_texture_small_mipmap = "false" # Mipmapping causes artifacts with manually resized masks without tex2Dlod +mask_slot_texture_large_mipmap = "true" # Essential for hardware-resized masks +mask_shadow_texture_small_mipmap = "false" # Mipmapping causes artifacts with manually resized masks without tex2Dlod +mask_shadow_texture_large_mipmap = "true" # Essential for hardware-resized masks + + +# Pass1: Linearize the input based on CRT gamma and bob interlaced fields. +# (Bobbing ensures we can immediately blur without getting artifacts.) +shader1 = "shaders/crt-royale/src/crt-royale-first-pass-linearize-crt-gamma-bob-fields.glsl" +alias1 = "ORIG_LINEARIZED" +filter_linear1 = "false" +scale_type1 = "source" +scale1 = "1.0" +srgb_framebuffer1 = "true" + +# Pass2: Resample interlaced (and misconverged) scanlines vertically. +# Separating vertical/horizontal scanline sampling is faster: It lets us +# consider more scanlines while calculating weights for fewer pixels, and +# it reduces our samples from vertical*horizontal to vertical+horizontal. +# This has to come right after ORIG_LINEARIZED, because there's no +# "original_source" scale_type we can use later. +shader2 = "shaders/crt-royale/src/crt-royale-scanlines-vertical-interlacing.glsl" +alias2 = "VERTICAL_SCANLINES" +filter_linear2 = "true" +scale_type_x2 = "source" +scale_x2 = "1.0" +scale_type_y2 = "viewport" +scale_y2 = "1.0" +#float_framebuffer2 = "true" +srgb_framebuffer2 = "true" + +# Pass3: Do a small resize blur of ORIG_LINEARIZED at an absolute size, and +# account for convergence offsets. We want to blur a predictable portion of the +# screen to match the phosphor bloom, and absolute scale works best for +# reliable results with a fixed-size bloom. Picking a scale is tricky: +# a.) 400x300 is a good compromise for the "fake-bloom" version: It's low enough +# to blur high-res/interlaced sources but high enough that resampling +# doesn't smear low-res sources too much. +# b.) 320x240 works well for the "real bloom" version: It's 1-1.5% faster, and +# the only noticeable visual difference is a larger halation spread (which +# may be a good thing for people who like to crank it up). +# Note the 4:3 aspect ratio assumes the input has cropped geom_overscan (so it's +# *intended* for an ~4:3 aspect ratio). +shader3 = "shaders/crt-royale/src/crt-royale-bloom-approx.glsl" +alias3 = "BLOOM_APPROX" +filter_linear3 = "true" +scale_type3 = "absolute" +scale_x3 = "320" +scale_y3 = "240" +srgb_framebuffer3 = "true" + +# Pass4: Vertically blur the input for halation and refractive diffusion. +# Base this on BLOOM_APPROX: This blur should be small and fast, and blurring +# a constant portion of the screen is probably physically correct if the +# viewport resolution is proportional to the simulated CRT size. +shader4 = "../blurs/shaders/royale/blur9fast-vertical.glsl" +filter_linear4 = "true" +scale_type4 = "source" +scale4 = "1.0" +srgb_framebuffer4 = "true" + +# Pass5: Horizontally blur the input for halation and refractive diffusion. +# Note: Using a one-pass 9x9 blur is about 1% slower. +shader5 = "../blurs/shaders/royale/blur9fast-horizontal.glsl" +alias5 = "HALATION_BLUR" +filter_linear5 = "true" +scale_type5 = "source" +scale5 = "1.0" +srgb_framebuffer5 = "true" + +# Pass6: Lanczos-resize the phosphor mask vertically. Set the absolute +# scale_x5 == mask_texture_small_size.x (see IMPORTANT above). Larger scales +# will blur, and smaller scales could get nasty. The vertical size must be +# based on the viewport size and calculated carefully to avoid artifacts later. +# First calculate the minimum number of mask tiles we need to draw. +# Since curvature is computed after the scanline masking pass: +# num_resized_mask_tiles = 2.0; +# If curvature were computed in the scanline masking pass (it's not): +# max_mask_texel_border = ~3.0 * (1/3.0 + 4.0*sqrt(2.0) + 0.5 + 1.0); +# max_mask_tile_border = max_mask_texel_border/ +# (min_resized_phosphor_triad_size * mask_triads_per_tile); +# num_resized_mask_tiles = max(2.0, 1.0 + max_mask_tile_border * 2.0); +# At typical values (triad_size >= 2.0, mask_triads_per_tile == 8): +# num_resized_mask_tiles = ~3.8 +# Triad sizes are given in horizontal terms, so we need geom_max_aspect_ratio +# to relate them to vertical resolution. The widest we expect is: +# geom_max_aspect_ratio = 4.0/3.0 # Note: Shader passes need to know this! +# The fewer triads we tile across the screen, the larger each triad will be as a +# fraction of the viewport size, and the larger scale_y5 must be to draw a full +# num_resized_mask_tiles. Therefore, we must decide the smallest number of +# triads we'll guarantee can be displayed on screen. We'll set this according +# to 3-pixel triads at 768p resolution (the lowest anyone's likely to use): +# min_allowed_viewport_triads = 768.0*geom_max_aspect_ratio / 3.0 = 341.333333 +# Now calculate the viewport scale that ensures we can draw resized_mask_tiles: +# min_scale_x = resized_mask_tiles * mask_triads_per_tile / +# min_allowed_viewport_triads +# scale_y6 = geom_max_aspect_ratio * min_scale_x +# # Some code might depend on equal scales: +# scale_x7 = scale_y6 +# Given our default geom_max_aspect_ratio and min_allowed_viewport_triads: +# scale_y6 = 4.0/3.0 * 2.0/(341.33333 / 8.0) = 0.0625 +# IMPORTANT: The scales MUST be calculated in this way. If you wish to change +# geom_max_aspect_ratio, update that constant in user-cgp-constants.h! +shader6 = "shaders/crt-royale/src/crt-royale-mask-resize-vertical.glsl" +filter_linear6 = "true" +scale_type_x6 = "absolute" +scale_x6 = "64" +scale_type_y6 = "viewport" +scale_y6 = "0.0625" # Safe for >= 341.333 horizontal triads at viewport size +#srgb_framebuffer6 = "false" # mask_texture is already assumed linear + +# Pass7: Lanczos-resize the phosphor mask horizontally. scale_x7 = scale_y6. +# TODO: Check again if the shaders actually require equal scales. +shader7 = "shaders/crt-royale/src/crt-royale-mask-resize-horizontal.glsl" +alias7 = "MASK_RESIZE" +filter_linear7 = "false" +scale_type_x7 = "viewport" +scale_x7 = "0.0625" +scale_type_y7 = "source" +scale_y7 = "1.0" +#srgb_framebuffer7 = "false" # mask_texture is already assumed linear + +# Pass8: Resample (misconverged) scanlines horizontally, apply halation, and +# apply the phosphor mask. +shader8 = "shaders/crt-royale/src/crt-royale-scanlines-horizontal-apply-mask.glsl" +alias8 = "MASKED_SCANLINES" +filter_linear8 = "true" # This could just as easily be nearest neighbor. +scale_type8 = "viewport" +scale8 = "1.0" +#float_framebuffer8 = "true" +srgb_framebuffer8 = "true" + +# Pass 9: Compute a brightpass. This will require reading the final mask. +shader9 = "shaders/crt-royale/src/crt-royale-brightpass.glsl" +alias9 = "BRIGHTPASS" +filter_linear9 = "true" # This could just as easily be nearest neighbor. +scale_type9 = "viewport" +scale9 = "1.0" +srgb_framebuffer9 = "true" + +# Pass 10: Blur the brightpass vertically +shader10 = "shaders/crt-royale/src/crt-royale-bloom-vertical.glsl" +filter_linear10 = "true" # This could just as easily be nearest neighbor. +scale_type10 = "source" +scale10 = "1.0" +srgb_framebuffer10 = "true" + +# Pass 11: Blur the brightpass horizontally and combine it with the dimpass: +shader11 = "shaders/crt-royale/src/crt-royale-bloom-horizontal-reconstitute.glsl" +filter_linear11 = "true" +scale_type11 = "source" +scale11 = "1.0" +srgb_framebuffer11 = "true" + +# Pass 12: Compute curvature/AA: +shader12 = "shaders/crt-royale/src/crt-royale-geometry-aa-last-pass.glsl" +filter_linear12 = "true" +scale_type12 = "viewport" +mipmap_input12 = "true" +texture_wrap_mode12 = "clamp_to_edge" diff --git a/crt/crt-royale.glslp b/crt/crt-royale.glslp new file mode 100644 index 0000000..2c6682d --- /dev/null +++ b/crt/crt-royale.glslp @@ -0,0 +1,203 @@ +# IMPORTANT: +# Shader passes need to know details about the image in the mask_texture LUT +# files, so set the following constants in user-preset-constants.h accordingly: +# 1.) mask_triads_per_tile = (number of horizontal triads in mask texture LUT's) +# 2.) mask_texture_small_size = (texture size of mask*texture_small LUT's) +# 3.) mask_texture_large_size = (texture size of mask*texture_large LUT's) +# 4.) mask_grille_avg_color = (avg. brightness of mask_grille_texture* LUT's, in [0, 1]) +# 5.) mask_slot_avg_color = (avg. brightness of mask_slot_texture* LUT's, in [0, 1]) +# 6.) mask_shadow_avg_color = (avg. brightness of mask_shadow_texture* LUT's, in [0, 1]) +# Shader passes also need to know certain scales set in this preset, but their +# compilation model doesn't currently allow the preset file to tell them. Make +# sure to set the following constants in user-preset-constants.h accordingly too: +# 1.) bloom_approx_scale_x = scale_x2 +# 2.) mask_resize_viewport_scale = vec2(scale_x6, scale_y5) +# Finally, shader passes need to know the value of geom_max_aspect_ratio used to +# calculate scale_y5 (among other values): +# 1.) geom_max_aspect_ratio = (geom_max_aspect_ratio used to calculate scale_y5) + +shaders = "12" + +# Set an identifier, filename, and sampling traits for the phosphor mask texture. +# Load an aperture grille, slot mask, and an EDP shadow mask, and load a small +# non-mipmapped version and a large mipmapped version. +# TODO: Test masks in other directories. +textures = "mask_grille_texture_small;mask_grille_texture_large;mask_slot_texture_small;mask_slot_texture_large;mask_shadow_texture_small;mask_shadow_texture_large" +mask_grille_texture_small = "shaders/crt-royale/TileableLinearApertureGrille15Wide8And5d5SpacingResizeTo64.png" +mask_grille_texture_large = "shaders/crt-royale/TileableLinearApertureGrille15Wide8And5d5Spacing.png" +mask_slot_texture_small = "shaders/crt-royale/TileableLinearSlotMaskTall15Wide9And4d5Horizontal9d14VerticalSpacingResizeTo64.png" +mask_slot_texture_large = "shaders/crt-royale/TileableLinearSlotMaskTall15Wide9And4d5Horizontal9d14VerticalSpacing.png" +mask_shadow_texture_small = "shaders/crt-royale/TileableLinearShadowMaskEDPResizeTo64.png" +mask_shadow_texture_large = "shaders/crt-royale/TileableLinearShadowMaskEDP.png" +mask_grille_texture_small_wrap_mode = "repeat" +mask_grille_texture_large_wrap_mode = "repeat" +mask_slot_texture_small_wrap_mode = "repeat" +mask_slot_texture_large_wrap_mode = "repeat" +mask_shadow_texture_small_wrap_mode = "repeat" +mask_shadow_texture_large_wrap_mode = "repeat" +mask_grille_texture_small_linear = "true" +mask_grille_texture_large_linear = "true" +mask_slot_texture_small_linear = "true" +mask_slot_texture_large_linear = "true" +mask_shadow_texture_small_linear = "true" +mask_shadow_texture_large_linear = "true" +mask_grille_texture_small_mipmap = "false" # Mipmapping causes artifacts with manually resized masks without tex2Dlod +mask_grille_texture_large_mipmap = "true" # Essential for hardware-resized masks +mask_slot_texture_small_mipmap = "false" # Mipmapping causes artifacts with manually resized masks without tex2Dlod +mask_slot_texture_large_mipmap = "true" # Essential for hardware-resized masks +mask_shadow_texture_small_mipmap = "false" # Mipmapping causes artifacts with manually resized masks without tex2Dlod +mask_shadow_texture_large_mipmap = "true" # Essential for hardware-resized masks + + +# Pass0: Linearize the input based on CRT gamma and bob interlaced fields. +# (Bobbing ensures we can immediately blur without getting artifacts.) +shader0 = "shaders/crt-royale/src/crt-royale-first-pass-linearize-crt-gamma-bob-fields.glsl" +alias0 = "ORIG_LINEARIZED" +filter_linear0 = "false" +scale_type0 = "source" +scale0 = "1.0" +srgb_framebuffer0 = "true" + +# Pass1: Resample interlaced (and misconverged) scanlines vertically. +# Separating vertical/horizontal scanline sampling is faster: It lets us +# consider more scanlines while calculating weights for fewer pixels, and +# it reduces our samples from vertical*horizontal to vertical+horizontal. +# This has to come right after ORIG_LINEARIZED, because there's no +# "original_source" scale_type we can use later. +shader1 = "shaders/crt-royale/src/crt-royale-scanlines-vertical-interlacing.glsl" +alias1 = "VERTICAL_SCANLINES" +filter_linear1 = "true" +scale_type_x1 = "source" +scale_x1 = "1.0" +scale_type_y1 = "viewport" +scale_y1 = "1.0" +srgb_framebuffer1 = "true" + +# Pass2: Do a small resize blur of ORIG_LINEARIZED at an absolute size, and +# account for convergence offsets. We want to blur a predictable portion of the +# screen to match the phosphor bloom, and absolute scale works best for +# reliable results with a fixed-size bloom. Picking a scale is tricky: +# a.) 400x300 is a good compromise for the "fake-bloom" version: It's low enough +# to blur high-res/interlaced sources but high enough that resampling +# doesn't smear low-res sources too much. +# b.) 320x240 works well for the "real bloom" version: It's 1-1.5% faster, and +# the only noticeable visual difference is a larger halation spread (which +# may be a good thing for people who like to crank it up). +# Note the 4:3 aspect ratio assumes the input has cropped geom_overscan (so it's +# *intended* for an ~4:3 aspect ratio). +shader2 = "shaders/crt-royale/src/crt-royale-bloom-approx.glsl" +alias2 = "BLOOM_APPROX" +filter_linear2 = "true" +scale_type2 = "absolute" +scale_x2 = "320" +scale_y2 = "240" +srgb_framebuffer2 = "true" + +# Pass3: Vertically blur the input for halation and refractive diffusion. +# Base this on BLOOM_APPROX: This blur should be small and fast, and blurring +# a constant portion of the screen is probably physically correct if the +# viewport resolution is proportional to the simulated CRT size. +shader3 = "../blurs/shaders/royale/blur9fast-vertical.glsl" +filter_linear3 = "true" +scale_type3 = "source" +scale3 = "1.0" +srgb_framebuffer3 = "true" + +# Pass4: Horizontally blur the input for halation and refractive diffusion. +# Note: Using a one-pass 9x9 blur is about 1% slower. +shader4 = "../blurs/shaders/royale/blur9fast-horizontal.glsl" +alias4 = "HALATION_BLUR" +filter_linear4 = "true" +scale_type4 = "source" +scale4 = "1.0" +srgb_framebuffer4 = "true" + +# Pass5: Lanczos-resize the phosphor mask vertically. Set the absolute +# scale_x5 == mask_texture_small_size.x (see IMPORTANT above). Larger scales +# will blur, and smaller scales could get nasty. The vertical size must be +# based on the viewport size and calculated carefully to avoid artifacts later. +# First calculate the minimum number of mask tiles we need to draw. +# Since curvature is computed after the scanline masking pass: +# num_resized_mask_tiles = 2.0; +# If curvature were computed in the scanline masking pass (it's not): +# max_mask_texel_border = ~3.0 * (1/3.0 + 4.0*sqrt(2.0) + 0.5 + 1.0); +# max_mask_tile_border = max_mask_texel_border/ +# (min_resized_phosphor_triad_size * mask_triads_per_tile); +# num_resized_mask_tiles = max(2.0, 1.0 + max_mask_tile_border * 2.0); +# At typical values (triad_size >= 2.0, mask_triads_per_tile == 8): +# num_resized_mask_tiles = ~3.8 +# Triad sizes are given in horizontal terms, so we need geom_max_aspect_ratio +# to relate them to vertical resolution. The widest we expect is: +# geom_max_aspect_ratio = 4.0/3.0 # Note: Shader passes need to know this! +# The fewer triads we tile across the screen, the larger each triad will be as a +# fraction of the viewport size, and the larger scale_y5 must be to draw a full +# num_resized_mask_tiles. Therefore, we must decide the smallest number of +# triads we'll guarantee can be displayed on screen. We'll set this according +# to 3-pixel triads at 768p resolution (the lowest anyone's likely to use): +# min_allowed_viewport_triads = 768.0*geom_max_aspect_ratio / 3.0 = 341.333333 +# Now calculate the viewport scale that ensures we can draw resized_mask_tiles: +# min_scale_x = resized_mask_tiles * mask_triads_per_tile / +# min_allowed_viewport_triads +# scale_y5 = geom_max_aspect_ratio * min_scale_x +# # Some code might depend on equal scales: +# scale_x6 = scale_y5 +# Given our default geom_max_aspect_ratio and min_allowed_viewport_triads: +# scale_y5 = 4.0/3.0 * 2.0/(341.33333 / 8.0) = 0.0625 +# IMPORTANT: The scales MUST be calculated in this way. If you wish to change +# geom_max_aspect_ratio, update that constant in user-preset-constants.h! +shader5 = "shaders/crt-royale/src/crt-royale-mask-resize-vertical.glsl" +filter_linear5 = "true" +scale_type_x5 = "absolute" +scale_x5 = "64" +scale_type_y5 = "viewport" +scale_y5 = "0.0625" # Safe for >= 341.333 horizontal triads at viewport size +#srgb_framebuffer5 = "false" # mask_texture is already assumed linear + +# Pass6: Lanczos-resize the phosphor mask horizontally. scale_x6 = scale_y5. +# TODO: Check again if the shaders actually require equal scales. +shader6 = "shaders/crt-royale/src/crt-royale-mask-resize-horizontal.glsl" +alias6 = "MASK_RESIZE" +filter_linear6 = "false" +scale_type_x6 = "viewport" +scale_x6 = "0.0625" +scale_type_y6 = "source" +scale_y6 = "1.0" +#srgb_framebuffer6 = "false" # mask_texture is already assumed linear + +# Pass7: Resample (misconverged) scanlines horizontally, apply halation, and +# apply the phosphor mask. +shader7 = "shaders/crt-royale/src/crt-royale-scanlines-horizontal-apply-mask.glsl" +alias7 = "MASKED_SCANLINES" +filter_linear7 = "true" # This could just as easily be nearest neighbor. +scale_type7 = "viewport" +scale7 = "1.0" +srgb_framebuffer7 = "true" + +# Pass 8: Compute a brightpass. This will require reading the final mask. +shader8 = "shaders/crt-royale/src/crt-royale-brightpass.glsl" +alias8 = "BRIGHTPASS" +filter_linear8 = "true" # This could just as easily be nearest neighbor. +scale_type8 = "viewport" +scale8 = "1.0" +srgb_framebuffer8 = "true" + +# Pass 9: Blur the brightpass vertically +shader9 = "shaders/crt-royale/src/crt-royale-bloom-vertical.glsl" +filter_linear9 = "true" # This could just as easily be nearest neighbor. +scale_type9 = "source" +scale9 = "1.0" +srgb_framebuffer9 = "true" + +# Pass 10: Blur the brightpass horizontally and combine it with the dimpass: +shader10 = "shaders/crt-royale/src/crt-royale-bloom-horizontal-reconstitute.glsl" +filter_linear10 = "true" +scale_type10 = "source" +scale10 = "1.0" +srgb_framebuffer10 = "true" + +# Pass 11: Compute curvature/AA: +shader11 = "shaders/crt-royale/src/crt-royale-geometry-aa-last-pass.glsl" +filter_linear11 = "true" +scale_type11 = "viewport" +mipmap_input11 = "false" +texture_wrap_mode11 = "clamp_to_edge" diff --git a/crt/crt-sines.glslp b/crt/crt-sines.glslp new file mode 100644 index 0000000..3c0f785 --- /dev/null +++ b/crt/crt-sines.glslp @@ -0,0 +1,27 @@ +shaders = "5" +feedback_pass = "0" +shader0 = "shaders/crt-consumer/linearize.glsl" +filter_linear0 = "false" +scale_type_x0 = "source" +scale_x0 = "1.000000" +scale_type_y0 = "source" +scale_y0 = "1.000000" +shader1 = "shaders/crt-consumer/glow_x.glsl" +filter_linear1 = "true"" +scale_type_x1 = "source" +scale_x1 = "1.000000" +scale_type_y1 = "source" +scale_y1 = "1.000000" +shader2 = "shaders/crt-consumer/glow_y.glsl" +filter_linear2 = "true" +scale_type_x2 = "source" +scale_x2 = "1.000000" +scale_type_y2 = "source" +scale_y2 = "1.000000" +shader3 = "shaders/crt-consumer/resolve.glsl" +scale_type_x3 = "source" +scale_x3 = "1.000000" +scale_type_y3 = "source" +scale_y3 = "1.000000" +shader4 = "shaders/crt-sines.glsl" +filter_linear4 = "true" diff --git a/crt/crt-torridgristle.glslp b/crt/crt-torridgristle.glslp new file mode 100644 index 0000000..f3cc366 --- /dev/null +++ b/crt/crt-torridgristle.glslp @@ -0,0 +1,44 @@ +shaders = 7 + +shader0 = shaders/torridgristle/Scanline-Interpolation.glsl +filter_linear0 = true +scale_type0 = source + +shader1 = shaders/torridgristle/ScanlineSimple.glsl +filter_linear1 = true +scale_type1 = source +scale1 = 3.0 + +shader2 = ../reshade/shaders/blendoverlay/blendoverlay.glsl +filter_linear2 = true +scale_type2 = viewport + +shader3 = shaders/torridgristle/Brighten.glsl +filter_linear3 = true +alias3 = candy_ref + +shader4 = shaders/torridgristle/sunset-gaussian-vert.glsl +filter_linear4 = true +scale_type4 = source + +shader5 = shaders/torridgristle/sunset-gaussian-horiz.glsl +filter_linear5 = true +scale_type5 = source + +shader6 = shaders/torridgristle/Candy-Bloom.glsl +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/crt-yo6-KV-M1420B-fast.glslp b/crt/crt-yo6-KV-M1420B-fast.glslp new file mode 100644 index 0000000..aff417e --- /dev/null +++ b/crt/crt-yo6-KV-M1420B-fast.glslp @@ -0,0 +1,22 @@ +shaders = 3 + +shader0 = "shaders/crt-yo6/crt-yo6-native-resolution.glsl" +filter_linear0 = true +wrap_mode0 = "clamp_to_edge" +scale_type0 = "absolute" +scale_x0 = 439 +scale_y0 = 233 + +shader1 = "shaders/crt-yo6/crt-yo6-warp.glsl" +filter_linear1 = true +wrap_mode1 = "clamp_to_edge" +scale_type1 = "absolute" +scale_x1 = 1684 +scale_y1 = 1329 + +shader2 = "../stock.glsl" +filter_linear2 = true + +textures = TEX_CRT +TEX_CRT = "shaders/crt-yo6/KV-M1420B.png" +TEX_CRT_linear = false diff --git a/crt/crt-yo6-KV-M1420B-sharp.glslp b/crt/crt-yo6-KV-M1420B-sharp.glslp new file mode 100644 index 0000000..c25db07 --- /dev/null +++ b/crt/crt-yo6-KV-M1420B-sharp.glslp @@ -0,0 +1,27 @@ +shaders = 3 + +shader0 = "shaders/crt-yo6/crt-yo6-native-resolution.glsl" +filter_linear0 = true +wrap_mode0 = "clamp_to_edge" +scale_type0 = "absolute" +scale_x0 = 439 +scale_y0 = 233 + +shader1 = "shaders/crt-yo6/crt-yo6-warp.glsl" +filter_linear1 = true +wrap_mode1 = "clamp_to_edge" +scale_type1 = "absolute" +scale_x1 = 1684 +scale_y1 = 1329 + +shader2 = "../windowed/shaders/jinc2-params.glsl" +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.glslp b/crt/crt-yo6-KV-M1420B.glslp new file mode 100644 index 0000000..500790d --- /dev/null +++ b/crt/crt-yo6-KV-M1420B.glslp @@ -0,0 +1,27 @@ +shaders = 3 + +shader0 = "shaders/crt-yo6/crt-yo6-native-resolution.glsl" +filter_linear0 = true +wrap_mode0 = "clamp_to_edge" +scale_type0 = "absolute" +scale_x0 = 439 +scale_y0 = 233 + +shader1 = "shaders/crt-yo6/crt-yo6-warp.glsl" +filter_linear1 = true +wrap_mode1 = "clamp_to_edge" +scale_type1 = "absolute" +scale_x1 = 1684 +scale_y1 = 1329 + +shader2 = "../windowed/shaders/jinc2-params.glsl" +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/crtglow_gauss.glslp b/crt/crtglow_gauss.glslp new file mode 100644 index 0000000..66cd411 --- /dev/null +++ b/crt/crtglow_gauss.glslp @@ -0,0 +1,38 @@ +shaders = 7 + +shader0 = shaders/glow/linearize.glsl +filter_linear0 = false +srgb_framebuffer0 = true + +shader1 = shaders/glow/gauss_horiz.glsl +filter_linear1 = false +scale_type_x1 = viewport +scale_type_y1 = source +scale_x0 = 1.0 +scale_y0 = 1.0 +srgb_framebuffer1 = true + +shader2 = shaders/glow/gauss_vert.glsl +filter_linear2 = false +scale_type2 = viewport +scale2 = 1.0 +srgb_framebuffer2 = true + +shader3 = shaders/glow/threshold.glsl +filter_linear3 = false +srgb_framebuffer3 = true + +shader4 = shaders/glow/blur_horiz.glsl +mipmap_input4 = true +filter_linear4 = true +scale_type4 = source +scale4 = 0.25 +srgb_framebuffer4 = true + +shader5 = shaders/glow/blur_vert.glsl +filter_linear5 = true +srgb_framebuffer5 = true + +shader6 = shaders/glow/resolve.glsl +filter_linear6 = true + diff --git a/crt/crtglow_gauss_ntsc_3phase.glslp b/crt/crtglow_gauss_ntsc_3phase.glslp new file mode 100644 index 0000000..c22edb2 --- /dev/null +++ b/crt/crtglow_gauss_ntsc_3phase.glslp @@ -0,0 +1,49 @@ +shaders = 8 + +shader0 = ../ntsc/shaders/ntsc-pass1-composite-3phase.glsl +filter_linear0 = false +scale_type0 = source +scale_x0 = 4.0 +scale_y0 = 1.0 +frame_count_mod0 = 2 +float_framebuffer0 = true + +shader1 = ../ntsc/shaders/ntsc-pass2-3phase-linear.glsl +scale_type1 = source +scale_x1 = 0.5 +scale_y1 = 1.0 +filter_linear1 = false +srgb_framebuffer1 = true + +shader2 = shaders/glow/gauss_horiz.glsl +filter_linear2 = false +scale_type_x2 = viewport +scale_type_y2 = source +scale_x2 = 1.0 +scale_y2 = 1.0 +srgb_framebuffer2 = true + +shader3 = shaders/glow/gauss_vert.glsl +filter_linear3 = false +scale_type3 = viewport +scale3 = 1.0 +srgb_framebuffer3 = true + +shader4 = shaders/glow/threshold.glsl +filter_linear4 = false +srgb_framebuffer4 = true + +shader5 = shaders/glow/blur_horiz.glsl +mipmap_input5 = true +filter_linear5 = true +scale_type5 = source +scale5 = 0.25 +srgb_framebuffer5 = true + +shader6 = shaders/glow/blur_vert.glsl +filter_linear6 = true +srgb_framebuffer6 = true + +shader7 = shaders/glow/resolve.glsl +filter_linear7 = true + diff --git a/crt/crtglow_lanczos.glslp b/crt/crtglow_lanczos.glslp new file mode 100644 index 0000000..1d77d81 --- /dev/null +++ b/crt/crtglow_lanczos.glslp @@ -0,0 +1,38 @@ +shaders = 7 + +shader0 = shaders/glow/linearize.glsl +filter_linear0 = false +srgb_framebuffer0 = true + +shader1 = shaders/glow/lanczos_horiz.glsl +filter_linear1 = false +scale_type_x1 = viewport +scale_type_y1 = source +scale_x1 = 1.0 +scale_y1 = 1.0 +srgb_framebuffer1 = true + +shader2 = shaders/glow/gauss_vert.glsl +filter_linear2 = false +scale_type2 = viewport +scale2 = 1.0 +srgb_framebuffer2 = true + +shader3 = shaders/glow/threshold.glsl +filter_linear3 = false +srgb_framebuffer3 = true + +shader4 = shaders/glow/blur_horiz.glsl +mipmap_input4 = true +filter_linear4 = true +scale_type4 = source +scale4 = 0.25 +srgb_framebuffer4 = true + +shader5 = shaders/glow/blur_vert.glsl +filter_linear5 = true +srgb_framebuffer5 = true + +shader6 = shaders/glow/resolve.glsl +filter_linear6 = true + diff --git a/crt/crtsim.glslp b/crt/crtsim.glslp new file mode 100644 index 0000000..8ad98f5 --- /dev/null +++ b/crt/crtsim.glslp @@ -0,0 +1,23 @@ +shaders = 5 + +shader0 = shaders/crtsim/composite.glsl +filter_linear0 = false + +shader1 = ../stock.glsl +alias1 = CRTPASS + +shader2 = shaders/crtsim/post-downsample.glsl +filter_linear2 = true + +shader3 = shaders/crtsim/post-upsample.glsl +filter_linear3 = true + +shader4 = shaders/crtsim/present.glsl +filter_linear4 = true + +textures = "NTSCArtifactSampler;shadowMaskSampler" +NTSCArtifactSampler = "shaders/crtsim/artifacts.png" +NTSCArtifactSampler_linear = true +shadowMaskSampler = "shaders/crtsim/mask.png" +shadowMaskSampler_linear = true +shadowMaskSampler_repeat = true \ No newline at end of file diff --git a/crt/fake-CRT-Geom-potato.glslp b/crt/fake-CRT-Geom-potato.glslp new file mode 100644 index 0000000..332ac35 --- /dev/null +++ b/crt/fake-CRT-Geom-potato.glslp @@ -0,0 +1,4 @@ +shaders = "1" +feedback_pass = "0" +shader0 = shaders/fake-CRT-Geom-potato.glsl +filter_linear0 = "true" diff --git a/crt/fake-CRT-Geom.glslp b/crt/fake-CRT-Geom.glslp new file mode 100644 index 0000000..750b2ba --- /dev/null +++ b/crt/fake-CRT-Geom.glslp @@ -0,0 +1,5 @@ +shaders = "1" +feedback_pass = "0" +shader0 = shaders/fake-CRT-Geom.glsl +filter_linear0 = "true" + diff --git a/crt/fakelottes.glslp b/crt/fakelottes.glslp new file mode 100644 index 0000000..9e2cf6d --- /dev/null +++ b/crt/fakelottes.glslp @@ -0,0 +1,4 @@ +shaders = 1 + +shader0 = shaders/fakelottes.glsl +filter_linear0 = true \ No newline at end of file diff --git a/crt/gizmo-crt.glslp b/crt/gizmo-crt.glslp new file mode 100644 index 0000000..699a328 --- /dev/null +++ b/crt/gizmo-crt.glslp @@ -0,0 +1,14 @@ +shaders = "1" +shader0 = "shaders/gizmo-crt.glsl" +filter_linear0 = "true" +scale_type0 = viewport + +parameters = "BRIGHTNESS;HORIZONTAL_BLUR;VERTICAL_BLUR;BLUR_OFFSET;BGR_LCD_PATTERN;SHRINK" +CURVATURE_X = "0.0" +CURVATURE_Y = "0.0" +BRIGHTNESS = "0.5" +HORIZONTAL_BLUR = "0.0" +VERTICAL_BLUR = "0.0" +BLUR_OFFSET = "0.0" +BGR_LCD_PATTERN = "0.0" +SHRINK = "0.0" diff --git a/crt/gizmo-slotmask-crt.glslp b/crt/gizmo-slotmask-crt.glslp new file mode 100644 index 0000000..0a8556b --- /dev/null +++ b/crt/gizmo-slotmask-crt.glslp @@ -0,0 +1,22 @@ +shaders = "1" +shader0 = "shaders/gizmo-slotmask-crt.glsl" +filter_linear0 = "true" +wrap_mode0 = "clamp_to_border" +mipmap_input0 = "false" +alias0 = "" +float_framebuffer0 = "false" +srgb_framebuffer0 = "false" + +parameters = "BRIGHTNESS;HORIZONTAL_BLUR;VERTICAL_BLUR;BLUR_OFFSET;BGR_LCD_PATTERN;SHRINK;SNR;COLOUR_BLEEDING;GRID;SLOTMASK" +CURVATURE_X = "0.15" +CURVATURE_Y = "0.15" +BRIGHTNESS = "0.5" +HORIZONTAL_BLUR = "1.0" +VERTICAL_BLUR = "0.0" +BLUR_OFFSET = "0.65" +BGR_LCD_PATTERN = "0.0" +SHRINK = "0.0" +SNR = "2.6" +COLOUR_BLEEDING = "0.15" +GRID = "0.30" +SLOTMASK = "1.0" diff --git a/crt/gtuv50.glslp b/crt/gtuv50.glslp new file mode 100644 index 0000000..cc276c8 --- /dev/null +++ b/crt/gtuv50.glslp @@ -0,0 +1,19 @@ +shaders = 3 + +shader0 = shaders/gtu-v050/pass1.glsl +scale_type0 = source +scale0 = 1.0 +float_framebuffer0 = true + +shader1 = shaders/gtu-v050/pass2.glsl +scale_type_x1 = viewport +scale_x1 = 1.0 +scale_type_y1 = source +scale_y1 = 1.0 +filter_linear1 = false +float_framebuffer1 = true + +shader2 = shaders/gtu-v050/pass3.glsl +scale_type2 = viewport +scale2 = 1.0 +filter_linear2 = false diff --git a/crt/mame_hlsl.glslp b/crt/mame_hlsl.glslp new file mode 100644 index 0000000..761a649 --- /dev/null +++ b/crt/mame_hlsl.glslp @@ -0,0 +1,87 @@ +# info on how the passes come together can be found in mame/src/osd/modules/render/d3d/d3dhlsl.cpp +shaders = 12 + +# NTSC emulation doesn't work for some reason; replacing with stock shader +# shader0 = shaders/mame_ntsc.glsl +shader0 = shaders/mame_hlsl/shaders/mame_params.glsl +filter_linear0 = true +alias0 = NTSCPass +scale_type0 = source +scale0 = 1.0 + +shader1 = shaders/mame_hlsl/shaders/mame_color.glsl +alias1 = ColorPass +scale_type1 = source +scale1 = 1.0 +filter_linear1 = true + +shader2 = ../interpolation/shaders/sharp-bilinear.glsl +alias2 = PrescalePass +scale_type2 = source +filter_linear2 = true +scale2 = 4.0 + +shader3 = shaders/mame_hlsl/shaders/mame_deconverge.glsl +alias3 = DeconvergePass +filter_linear3 = true +scale_type3 = source +scale3 = 0.5 + +shader4 = shaders/mame_hlsl/shaders/mame_scanline.glsl +alias4 = ScanlinePass +filter_linear4 = true +scale_type4 = source +scale4 = 2.0 + +shader5 = shaders/mame_hlsl/shaders/mame_focus.glsl +alias5 = FocusPass +filter_linear5 = true + +shader6 = shaders/mame_hlsl/shaders/mame_phosphor.glsl +alias6 = PhosphorPass +filter_linear6 = true + +shader7 = shaders/mame_hlsl/shaders/mame_post.glsl +alias7 = PostPass +filter_linear7 = true +scale_type7 = viewport + +shader8 = shaders/mame_hlsl/shaders/mame_chroma.glsl +alias8 = ChromaPass +filter_linear8 = true +scale_type8 = viewport + +shader9 = shaders/mame_hlsl/shaders/mame_downsample.glsl +alias9 = DownsamplePass +filter_linear9 = true + +shader10 = shaders/mame_hlsl/shaders/mame_bloom.glsl +alias10 = BloomPass +filter_linear10 = true +scale_type10 = source +mipmap_input10 = true + +shader11 = shaders/mame_hlsl/shaders/mame_distortion.glsl +alias11 = DistortionPass +filter_linear11 = true + +# doesn't work so never actually ported +#shader12 = shaders/mame_hlsl/shaders/mame_vector.glsl +#alias12 = VectorPass +#filter_linear12 = true + +# mame's textures are available here: https://github.com/mamedev/mame/tree/master/artwork +textures = "MaskTexture" +MaskTexture = shaders/mame_hlsl/resources/aperture-grille.png + +parameters = "AUTO_PRESCALE;chromaa_x;chromaa_y;chromab_x;chromab_y;chromac_x;chromac_y;ygain_r;ygain_g;ygain_b" +chromaa_x = "0.630" +chromaa_y = "0.340" +chromab_x = "0.310" +chromab_y = "0.595" +chromac_x = "0.155" +chromac_y = "0.070" +ygain_r = "0.1875" +ygain_g = "0.6940" +ygain_b = "0.1185" +AUTO_PRESCALE = "0.0" diff --git a/crt/metacrt.glslp b/crt/metacrt.glslp new file mode 100644 index 0000000..181e5ca --- /dev/null +++ b/crt/metacrt.glslp @@ -0,0 +1,9 @@ +shaders = 1 + +shader0 = shaders/metacrt/bufC.glsl + +textures = "cubeMap;table" +cubeMap = shaders/metacrt/basilica.png +cubeMap_wrap_mode = repeat +table = shaders/metacrt/woodgrain.png +table_wrap_mode = repeat \ No newline at end of file diff --git a/crt/phosphorlut.glslp b/crt/phosphorlut.glslp new file mode 100644 index 0000000..8d3ac1a --- /dev/null +++ b/crt/phosphorlut.glslp @@ -0,0 +1,38 @@ +shaders = 5 + +shader0 = shaders/phosphorlut/scanlines-interlace-linearize.glsl +alias0 = firstPass +scale0 = 2.0 +scale_type0 = source +srgb_framebuffer0 = true +filter_linear0 = false + +shader1 = ../blurs/shaders/blur-gauss-v.glsl +scale_type1 = source +scale1 = 1.0 +srgb_framebuffer1 = true +filter_linear1 = true +alias1 = blurPassV + +shader2 = ../blurs/shaders/blur-gauss-h.glsl +alias2 = blurPass +filter_linear2 = true +scale2 = 1.0 +scale_type2 = source +srgb_framebuffer2 = true + +shader3 = shaders/phosphorlut/phosphorlut-pass0.glsl +alias3 = phosphorPass +filter_linear3 = true +scale_type3 = source +scale_x3 = 4.0 +scale_y3 = 2.0 +srgb_framebuffer3 = true + +shader4 = shaders/phosphorlut/phosphorlut-pass1.glsl +filter_linear4 = true + +textures = "shadow;aperture;slot" +shadow = shaders/phosphorlut/luts/shadowmask.png +aperture = shaders/phosphorlut/luts/aperture-grille.png +slot = shaders/phosphorlut/luts/slotmask.png \ No newline at end of file diff --git a/crt/smuberstep-glow.glslp b/crt/smuberstep-glow.glslp new file mode 100644 index 0000000..fc0ecc5 --- /dev/null +++ b/crt/smuberstep-glow.glslp @@ -0,0 +1,4 @@ +shaders = 1 + +shader0 = shaders/smuberstep-glow.glsl +filter_linear0 = true \ No newline at end of file diff --git a/crt/tvout-tweaks-linearized-multipass.glslp b/crt/tvout-tweaks-linearized-multipass.glslp new file mode 100644 index 0000000..3cb35d1 --- /dev/null +++ b/crt/tvout-tweaks-linearized-multipass.glslp @@ -0,0 +1,26 @@ +shaders = "2" + +shader0 = "shaders/tvout-tweaks-multipass/tvout-tweaks-pass-0.glsl" +float_framebuffer0 = "true" +srgb_framebuffer0 = "true" +scale_type_x0 = "source" +scale_x0 = "1.000000" +scale_type_y0 = "source" +scale_y0 = "1.000000" + +shader1 = "shaders/tvout-tweaks-multipass/tvout-tweaks-pass-1.glsl" +float_framebuffer1 = "false" +srgb_framebuffer1 = "false" +scale_type_x1 = "viewport" +scale_x1 = "1.000000" +scale_type_y1 = "source" +scale_y1 = "1.000000" + +parameters = "TVOUT_COMPOSITE_CONNECTION;TVOUT_TV_COLOR_LEVELS;TVOUT_RESOLUTION;TVOUT_RESOLUTION_Y;TVOUT_RESOLUTION_I;TVOUT_RESOLUTION_Q" + +TVOUT_COMPOSITE_CONNECTION = "0.000000" +TVOUT_RESOLUTION = "256.000000" +TVOUT_RESOLUTION_I = "83.199997" +TVOUT_RESOLUTION_Q = "25.600000" +TVOUT_RESOLUTION_Y = "256.000000" +TVOUT_TV_COLOR_LEVELS = "0.000000" \ No newline at end of file diff --git a/crt/yee64.glslp b/crt/yee64.glslp new file mode 100644 index 0000000..074e430 --- /dev/null +++ b/crt/yee64.glslp @@ -0,0 +1,3 @@ +shaders = 1 + +shader0 = shaders/yee64.glsl diff --git a/crt/yeetron.glslp b/crt/yeetron.glslp new file mode 100644 index 0000000..e50f0e0 --- /dev/null +++ b/crt/yeetron.glslp @@ -0,0 +1,4 @@ +shaders = 1 + +shader0 = shaders/yeetron.glsl +filter_linear0 = false diff --git a/crt/zfast-composite.glslp b/crt/zfast-composite.glslp new file mode 100644 index 0000000..d16282e --- /dev/null +++ b/crt/zfast-composite.glslp @@ -0,0 +1,3 @@ +shaders = "1" +shader0 = "shaders/zfast_crt_composite.glsl" +filter_linear0 = "true" diff --git a/crt/zfast-crt.glslp b/crt/zfast-crt.glslp new file mode 100644 index 0000000..3f35952 --- /dev/null +++ b/crt/zfast-crt.glslp @@ -0,0 +1,4 @@ +shaders = 1 + +shader0 = shaders/zfast_crt.glsl +filter_linear0 = true \ No newline at end of file diff --git a/crt/zfast_crt_geo.glslp b/crt/zfast_crt_geo.glslp new file mode 100644 index 0000000..e48b2b3 --- /dev/null +++ b/crt/zfast_crt_geo.glslp @@ -0,0 +1,9 @@ +shaders = "1" + +shader0 = "shaders/zfast_crt_geo.glsl" +filter_linear0 = "true" +wrap_mode0 = "clamp_to_border" +mipmap_input0 = "false" +alias0 = "" +float_framebuffer0 = "false" +srgb_framebuffer0 = "false" \ No newline at end of file diff --git a/crt/zfast_crt_geo_svideo.glslp b/crt/zfast_crt_geo_svideo.glslp new file mode 100644 index 0000000..916e4df --- /dev/null +++ b/crt/zfast_crt_geo_svideo.glslp @@ -0,0 +1,9 @@ +shaders = "1" + +shader0 = "shaders/zfast_crt_geo_svideo.glsl" +filter_linear0 = "true" +wrap_mode0 = "clamp_to_border" +mipmap_input0 = "false" +alias0 = "" +float_framebuffer0 = "false" +srgb_framebuffer0 = "false" \ No newline at end of file diff --git a/crt/zfast_crt_nogeo.glslp b/crt/zfast_crt_nogeo.glslp new file mode 100644 index 0000000..d012cc4 --- /dev/null +++ b/crt/zfast_crt_nogeo.glslp @@ -0,0 +1,9 @@ +shaders = "1" + +shader0 = "shaders/zfast_crt_nogeo.glsl" +filter_linear0 = "true" +wrap_mode0 = "clamp_to_border" +mipmap_input0 = "false" +alias0 = "" +float_framebuffer0 = "false" +srgb_framebuffer0 = "false" \ No newline at end of file diff --git a/crt/zfast_crt_nogeo_svideo.glslp b/crt/zfast_crt_nogeo_svideo.glslp new file mode 100644 index 0000000..46128dc --- /dev/null +++ b/crt/zfast_crt_nogeo_svideo.glslp @@ -0,0 +1,9 @@ +shaders = "1" + +shader0 = "shaders/zfast_crt_nogeo_svideo.glsl" +filter_linear0 = "true" +wrap_mode0 = "clamp_to_border" +mipmap_input0 = "false" +alias0 = "" +float_framebuffer0 = "false" +srgb_framebuffer0 = "false" \ No newline at end of file diff --git a/crtpi.glsl b/crtpi.glsl new file mode 100644 index 0000000..067a4fb --- /dev/null +++ b/crtpi.glsl @@ -0,0 +1,233 @@ +/* + crt-pi - A Raspberry Pi friendly CRT shader. + + Copyright (C) 2015-2016 davej + + 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. + + +Notes: + +This shader is designed to work well on Raspberry Pi GPUs (i.e. 1080P @ 60Hz on a game with a 4:3 aspect ratio). It pushes the Pi's GPU hard and enabling some features will slow it down so that it is no longer able to match 1080P @ 60Hz. You will need to overclock your Pi to the fastest setting in raspi-config to get the best results from this shader: 'Pi2' for Pi2 and 'Turbo' for original Pi and Pi Zero. Note: Pi2s are slower at running the shader than other Pis, this seems to be down to Pi2s lower maximum memory speed. Pi2s don't quite manage 1080P @ 60Hz - they drop about 1 in 1000 frames. You probably won't notice this, but if you do, try enabling FAKE_GAMMA. + +SCANLINES enables scanlines. You'll almost certainly want to use it with MULTISAMPLE to reduce moire effects. SCANLINE_WEIGHT defines how wide scanlines are (it is an inverse value so a higher number = thinner lines). SCANLINE_GAP_BRIGHTNESS defines how dark the gaps between the scan lines are. Darker gaps between scan lines make moire effects more likely. + +GAMMA enables gamma correction using the values in INPUT_GAMMA and OUTPUT_GAMMA. FAKE_GAMMA causes it to ignore the values in INPUT_GAMMA and OUTPUT_GAMMA and approximate gamma correction in a way which is faster than true gamma whilst still looking better than having none. You must have GAMMA defined to enable FAKE_GAMMA. + +CURVATURE distorts the screen by CURVATURE_X and CURVATURE_Y. Curvature slows things down a lot. + +By default the shader uses linear blending horizontally. If you find this too blury, enable SHARPER. + +BLOOM_FACTOR controls the increase in width for bright scanlines. + +MASK_TYPE defines what, if any, shadow mask to use. MASK_BRIGHTNESS defines how much the mask type darkens the screen. + +*/ + +#pragma parameter CURVATURE_X "Screen curvature - horizontal" 0.10 0.0 1.0 0.01 +#pragma parameter CURVATURE_Y "Screen curvature - vertical" 0.15 0.0 1.0 0.01 +#pragma parameter MASK_BRIGHTNESS "Mask brightness" 0.70 0.0 1.0 0.01 +#pragma parameter SCANLINE_WEIGHT "Scanline weight" 6.0 0.0 15.0 0.1 +#pragma parameter SCANLINE_GAP_BRIGHTNESS "Scanline gap brightness" 0.12 0.0 1.0 0.01 +#pragma parameter BLOOM_FACTOR "Bloom factor" 1.5 0.0 5.0 0.01 +#pragma parameter INPUT_GAMMA "Input gamma" 2.4 0.0 5.0 0.01 +#pragma parameter OUTPUT_GAMMA "Output gamma" 2.2 0.0 5.0 0.01 + +// Haven't put these as parameters as it would slow the code down. +#define SCANLINES +#define MULTISAMPLE +#define GAMMA +//#define FAKE_GAMMA +//#define CURVATURE +//#define SHARPER +// MASK_TYPE: 0 = none, 1 = green/magenta, 2 = trinitron(ish) +#define MASK_TYPE 1 + + +#ifdef GL_ES +#define COMPAT_PRECISION mediump +precision mediump float; +#else +#define COMPAT_PRECISION +#endif + +#ifdef PARAMETER_UNIFORM +uniform COMPAT_PRECISION float CURVATURE_X; +uniform COMPAT_PRECISION float CURVATURE_Y; +uniform COMPAT_PRECISION float MASK_BRIGHTNESS; +uniform COMPAT_PRECISION float SCANLINE_WEIGHT; +uniform COMPAT_PRECISION float SCANLINE_GAP_BRIGHTNESS; +uniform COMPAT_PRECISION float BLOOM_FACTOR; +uniform COMPAT_PRECISION float INPUT_GAMMA; +uniform COMPAT_PRECISION float OUTPUT_GAMMA; +#else +#define CURVATURE_X 0.10 +#define CURVATURE_Y 0.25 +#define MASK_BRIGHTNESS 0.70 +#define SCANLINE_WEIGHT 6.0 +#define SCANLINE_GAP_BRIGHTNESS 0.12 +#define BLOOM_FACTOR 1.5 +#define INPUT_GAMMA 2.4 +#define OUTPUT_GAMMA 2.2 +#endif + +/* COMPATIBILITY + - GLSL compilers +*/ + +uniform vec2 TextureSize; +#if defined(CURVATURE) +varying vec2 screenScale; +#endif +varying vec2 TEX0; +varying float filterWidth; + +#if defined(VERTEX) +uniform mat4 MVPMatrix; +attribute vec4 VertexCoord; +attribute vec2 TexCoord; +uniform vec2 InputSize; +uniform vec2 OutputSize; + +void main() +{ +#if defined(CURVATURE) + screenScale = TextureSize / InputSize; +#endif + filterWidth = (InputSize.y / OutputSize.y) / 3.0; + TEX0 = TexCoord*1.0001; + gl_Position = MVPMatrix * VertexCoord; +} +#elif defined(FRAGMENT) + +uniform sampler2D Texture; + +#if defined(CURVATURE) +vec2 Distort(vec2 coord) +{ + vec2 CURVATURE_DISTORTION = vec2(CURVATURE_X, CURVATURE_Y); + // Barrel distortion shrinks the display area a bit, this will allow us to counteract that. + vec2 barrelScale = 1.0 - (0.23 * CURVATURE_DISTORTION); + coord *= screenScale; + coord -= vec2(0.5); + float rsq = coord.x * coord.x + coord.y * coord.y; + coord += coord * (CURVATURE_DISTORTION * rsq); + coord *= barrelScale; + if (abs(coord.x) >= 0.5 || abs(coord.y) >= 0.5) + coord = vec2(-1.0); // If out of bounds, return an invalid value. + else + { + coord += vec2(0.5); + coord /= screenScale; + } + + return coord; +} +#endif + +float CalcScanLineWeight(float dist) +{ + return max(1.0-dist*dist*SCANLINE_WEIGHT, SCANLINE_GAP_BRIGHTNESS); +} + +float CalcScanLine(float dy) +{ + float scanLineWeight = CalcScanLineWeight(dy); +#if defined(MULTISAMPLE) + scanLineWeight += CalcScanLineWeight(dy-filterWidth); + scanLineWeight += CalcScanLineWeight(dy+filterWidth); + scanLineWeight *= 0.3333333; +#endif + return scanLineWeight; +} + +void main() +{ +#if defined(CURVATURE) + vec2 texcoord = Distort(TEX0); + if (texcoord.x < 0.0) + gl_FragColor = vec4(0.0); + else +#else + vec2 texcoord = TEX0; +#endif + { + vec2 texcoordInPixels = texcoord * TextureSize; +#if defined(SHARPER) + vec2 tempCoord = floor(texcoordInPixels) + 0.5; + vec2 coord = tempCoord / TextureSize; + vec2 deltas = texcoordInPixels - tempCoord; + float scanLineWeight = CalcScanLine(deltas.y); + vec2 signs = sign(deltas); + deltas.x *= 2.0; + deltas = deltas * deltas; + deltas.y = deltas.y * deltas.y; + deltas.x *= 0.5; + deltas.y *= 8.0; + deltas /= TextureSize; + deltas *= signs; + vec2 tc = coord + deltas; +#else + float tempY = floor(texcoordInPixels.y) + 0.5; + float yCoord = tempY / TextureSize.y; + float dy = texcoordInPixels.y - tempY; + float scanLineWeight = CalcScanLine(dy); + float signY = sign(dy); + dy = dy * dy; + dy = dy * dy; + dy *= 8.0; + dy /= TextureSize.y; + dy *= signY; + vec2 tc = vec2(texcoord.x, yCoord + dy); +#endif + + vec3 colour = texture2D(Texture, tc).rgb; + +#if defined(SCANLINES) +#if defined(GAMMA) +#if defined(FAKE_GAMMA) + colour = colour * colour; +#else + colour = pow(colour, vec3(INPUT_GAMMA)); +#endif +#endif + scanLineWeight *= BLOOM_FACTOR; + colour *= scanLineWeight; + +#if defined(GAMMA) +#if defined(FAKE_GAMMA) + colour = sqrt(colour); +#else + colour = pow(colour, vec3(1.0/OUTPUT_GAMMA)); +#endif +#endif +#endif +#if MASK_TYPE == 0 + gl_FragColor = vec4(colour, 1.0); +#else +#if MASK_TYPE == 1 + float whichMask = fract((gl_FragCoord.x*1.0001) * 0.5); + vec3 mask; + if (whichMask < 0.5) + mask = vec3(MASK_BRIGHTNESS, 1.0, MASK_BRIGHTNESS); + else + mask = vec3(1.0, MASK_BRIGHTNESS, 1.0); +#elif MASK_TYPE == 2 + float whichMask = fract((gl_FragCoord.x*1.0001) * 0.3333333); + vec3 mask = vec3(MASK_BRIGHTNESS, MASK_BRIGHTNESS, MASK_BRIGHTNESS); + if (whichMask < 0.3333333) + mask.x = 1.0; + else if (whichMask < 0.6666666) + mask.y = 1.0; + else + mask.z = 1.0; +#endif + + gl_FragColor = vec4(colour * mask, 1.0); +#endif + } +} +#endif diff --git a/main.cpp b/main.cpp index 8c3b8db..9a3372c 100644 --- a/main.cpp +++ b/main.cpp @@ -117,6 +117,10 @@ GLuint compileProgram(const char* vtxFile, const char* fragFile) { std::ifstream f(vtxFile); std::string source((std::istreambuf_iterator(f)), std::istreambuf_iterator()); + + /*const char *sources[2] = { "#define VERTEX\n", source.c_str() }; + glShaderSourceARB(shader, 2, sources, NULL);*/ + vtxShaderId = compileShader(source.c_str(), GL_VERTEX_SHADER); f=std::ifstream(fragFile); @@ -212,6 +216,15 @@ void initializeFileSystem() { #endif int main(int argc, char **argv){ + + if (argc < 2) { + std::cerr << "Uso: shaders [vertex shader] [fragment shader]" << "\n"; + std::cerr << " shaders [unique shader]" << "\n"; + return 1; + } + char *vertex_shader = argv[1]; + char *fragment_shader = argc<3 ? vertex_shader : argv[2]; + GLuint programId; #ifdef __APPLE__ @@ -245,7 +258,7 @@ int main(int argc, char **argv){ } #endif // Compilar el shader y dejarlo listo para usar. - programId = compileProgram("std.vertex", "crt.fragment"); + programId = compileProgram(vertex_shader, fragment_shader); std::cout << "programId = " << programId << std::endl; }