diff options
88 files changed, 1306 insertions, 0 deletions
diff --git a/artwork/bgfx/chains/crt-geom/aperture_1_2_bgr.png b/artwork/bgfx/chains/crt-geom/aperture_1_2_bgr.png Binary files differnew file mode 100644 index 00000000000..26c49ba1c81 --- /dev/null +++ b/artwork/bgfx/chains/crt-geom/aperture_1_2_bgr.png diff --git a/artwork/bgfx/chains/crt-geom/aperture_1_4_rgb.png b/artwork/bgfx/chains/crt-geom/aperture_1_4_rgb.png Binary files differnew file mode 100644 index 00000000000..1667e2abfac --- /dev/null +++ b/artwork/bgfx/chains/crt-geom/aperture_1_4_rgb.png diff --git a/artwork/bgfx/chains/crt-geom/aperture_2_4_rgb.png b/artwork/bgfx/chains/crt-geom/aperture_2_4_rgb.png Binary files differnew file mode 100644 index 00000000000..a4fce0e92ec --- /dev/null +++ b/artwork/bgfx/chains/crt-geom/aperture_2_4_rgb.png diff --git a/artwork/bgfx/chains/crt-geom/aperture_2_5_bgr.png b/artwork/bgfx/chains/crt-geom/aperture_2_5_bgr.png Binary files differnew file mode 100644 index 00000000000..0efddb5bcee --- /dev/null +++ b/artwork/bgfx/chains/crt-geom/aperture_2_5_bgr.png diff --git a/artwork/bgfx/chains/crt-geom/aperture_3_6_rgb.png b/artwork/bgfx/chains/crt-geom/aperture_3_6_rgb.png Binary files differnew file mode 100644 index 00000000000..8ebbb448786 --- /dev/null +++ b/artwork/bgfx/chains/crt-geom/aperture_3_6_rgb.png diff --git a/artwork/bgfx/chains/crt-geom/delta_1_2x1_bgr.png b/artwork/bgfx/chains/crt-geom/delta_1_2x1_bgr.png Binary files differnew file mode 100644 index 00000000000..497ca426474 --- /dev/null +++ b/artwork/bgfx/chains/crt-geom/delta_1_2x1_bgr.png diff --git a/artwork/bgfx/chains/crt-geom/delta_1_4x1_rgb.png b/artwork/bgfx/chains/crt-geom/delta_1_4x1_rgb.png Binary files differnew file mode 100644 index 00000000000..21144c3b183 --- /dev/null +++ b/artwork/bgfx/chains/crt-geom/delta_1_4x1_rgb.png diff --git a/artwork/bgfx/chains/crt-geom/delta_2_4x1_rgb.png b/artwork/bgfx/chains/crt-geom/delta_2_4x1_rgb.png Binary files differnew file mode 100644 index 00000000000..4a652631940 --- /dev/null +++ b/artwork/bgfx/chains/crt-geom/delta_2_4x1_rgb.png diff --git a/artwork/bgfx/chains/crt-geom/delta_2_4x2_rgb.png b/artwork/bgfx/chains/crt-geom/delta_2_4x2_rgb.png Binary files differnew file mode 100644 index 00000000000..9cba74f077d --- /dev/null +++ b/artwork/bgfx/chains/crt-geom/delta_2_4x2_rgb.png diff --git a/artwork/bgfx/chains/crt-geom/none.png b/artwork/bgfx/chains/crt-geom/none.png Binary files differnew file mode 100644 index 00000000000..31419a54ac9 --- /dev/null +++ b/artwork/bgfx/chains/crt-geom/none.png diff --git a/artwork/bgfx/chains/crt-geom/slot_2_4x4_rgb.png b/artwork/bgfx/chains/crt-geom/slot_2_4x4_rgb.png Binary files differnew file mode 100644 index 00000000000..695957eab7d --- /dev/null +++ b/artwork/bgfx/chains/crt-geom/slot_2_4x4_rgb.png diff --git a/artwork/bgfx/chains/crt-geom/slot_2_5x4_bgr.png b/artwork/bgfx/chains/crt-geom/slot_2_5x4_bgr.png Binary files differnew file mode 100644 index 00000000000..58d1651bc38 --- /dev/null +++ b/artwork/bgfx/chains/crt-geom/slot_2_5x4_bgr.png diff --git a/artwork/bgfx/chains/crt-geom/slot_3_7x6_rgb.png b/artwork/bgfx/chains/crt-geom/slot_3_7x6_rgb.png Binary files differnew file mode 100644 index 00000000000..86f72a7297a --- /dev/null +++ b/artwork/bgfx/chains/crt-geom/slot_3_7x6_rgb.png diff --git a/bgfx/chains/crt-geom-deluxe.json b/bgfx/chains/crt-geom-deluxe.json new file mode 100644 index 00000000000..b9a4b67820c --- /dev/null +++ b/bgfx/chains/crt-geom-deluxe.json @@ -0,0 +1,238 @@ +{ + "name": "CRT-geom", + "author": "cgwg", + "sliders": [ + { "type": "float", + "name": "aperture_strength", + "text": "Shadow mask strength", + "default": 0.4, + "max" : 1.0, + "min" : 0.0, + "step" : 0.05, + "format": "%1.2f", + "screen": "raster" }, + { "type": "float", + "name": "phosphor_power", + "text": "Phosphor decay power", + "default": 1.2, + "max" : 3.0, + "min" : 0.5, + "step" : 0.05, + "format": "%1.2f", + "screen": "raster" }, + { "type": "float", + "name": "phosphor_amplitude", + "text": "Phosphor persistence amplitude", + "default": 0.04, + "max" : 0.2, + "min" : 0.0, + "step" : 0.01, + "format": "%1.2f", + "screen": "raster" }, + { "type": "float", + "name": "halation", + "text": "Halation amplitude", + "default": 0.1, + "max" : 0.3, + "min" : 0.0, + "step" : 0.01, + "format": "%1.2f", + "screen": "raster" }, + { "type": "float", + "name": "blurwidth", + "text": "Halation blur width", + "default": 2.0, + "max" : 4.0, + "min" : 0.1, + "step" : 0.1, + "format": "%1.1f", + "screen": "raster" }, + { "type": "float", + "name": "curvature", + "text": "Enable curvature", + "default": 1.0, + "max" : 1.0, + "min" : 0.0, + "step" : 1.0, + "format": "%1.0f", + "screen": "raster" }, + { "type": "float", + "name": "R", + "text": "Radius of curvature", + "default": 3.5, + "max" : 10.0, + "min" : 0.5, + "step" : 0.1, + "format": "%1.1f", + "screen": "raster" }, + { "type": "float", + "name": "d", + "text": "Distance to screen", + "default": 2.0, + "max" : 10.0, + "min" : 0.1, + "step" : 0.1, + "format": "%1.1f", + "screen": "raster" }, + { "type": "vec2", + "name": "angle", + "text": "Tilt ", + "default": [ 0.0,-0.05 ], + "max" : [ 1.0, 1.0 ], + "min" : [-1.0,-1.0 ], + "step" : 0.01, + "format": "%1.2f", + "screen": "raster" }, + { "type": "float", + "name": "cornersize", + "text": "Rounded corner size", + "default": 0.01, + "max" : 0.10, + "min" : 0.00, + "step" : 0.01, + "format": "%1.2f", + "screen": "raster" }, + { "type": "float", + "name": "cornersmooth", + "text": "Border smoothness", + "default": 1000, + "max" : 2000, + "min" : 100, + "step" : 100, + "format": "%1.0f", + "screen": "raster" }, + { "type": "vec2", + "name": "overscan", + "text": "Overscan ", + "default": [ 1.0, 1.0 ], + "max" : [ 1.2, 1.2 ], + "min" : [ 0.8, 0.8 ], + "step" : 0.02, + "format": "%1.2f", + "screen": "raster" }, + { "type": "float", + "name": "CRTgamma", + "text": "Gamma of simulated CRT", + "default": 2.4, + "max" : 4.0, + "min" : 0.7, + "step" : 0.05, + "format": "%1.2f", + "screen": "raster" }, + { "type": "float", + "name": "monitorgamma", + "text": "Gamma of output display", + "default": 2.2, + "max" : 4.0, + "min" : 0.7, + "step" : 0.05, + "format": "%1.2f", + "screen": "raster" }, + { "type": "vec2", + "name": "aspect", + "text": "Aspect ratio ", + "default": [ 1.0, 0.75 ], + "max" : [ 1.0, 1.0 ], + "min" : [ 0.3, 0.3 ], + "step" : 0.01, + "format": "%1.2f", + "screen": "raster" } + ], + "targets": [ + { "name": "internal1", + "mode": "guest" + }, + { "name": "internal2", + "mode": "guest" + }, + { "name": "blur", + "mode": "guest" + }, + { "name": "phosphor", + "mode": "guest" + } + + ], + "passes": [ + { + "effect": "crt-geom/phosphor_apply", + "name": "phosphor apply", + "uniforms": [ + { "uniform": "u_phosphor_power", "slider": "phosphor_power" }, + { "uniform": "u_phosphor_amplitude","slider": "phosphor_amplitude" }, + { "uniform": "u_gamma", "slider": "CRTgamma" } + ], + "input": [ + { "sampler": "s_screen", "target": "screen" }, + { "sampler": "s_phosphor", "target": "phosphor" } + ], + "output": "internal1" + }, + { + "effect": "crt-geom/phosphor_update", + "name": "phosphor update", + "uniforms": [ + { "uniform": "u_phosphor_power", "slider": "phosphor_power" }, + { "uniform": "u_phosphor_amplitude","slider": "phosphor_amplitude" }, + { "uniform": "u_gamma", "slider": "CRTgamma" } + ], + "input": [ + { "sampler": "s_screen", "target": "screen" }, + { "sampler": "s_phosphor", "target": "phosphor" } + ], + "output": "phosphor" + }, + { + "effect": "crt-geom/gaussx", + "name": "Gaussian blur x", + "uniforms": [ + { "uniform": "u_width", "slider": "blurwidth" }, + { "uniform": "u_aspect","slider": "aspect" }, + { "uniform": "u_gamma", "slider": "CRTgamma" } + ], + "input": [ + { "sampler": "s_tex", "target": "internal1" } + ], + "output": "internal2" + }, + { + "effect": "crt-geom/gaussy", + "name": "Gaussian blur y", + "uniforms": [ + { "uniform": "u_width", "slider": "blurwidth" }, + { "uniform": "u_aspect","slider": "aspect" }, + { "uniform": "u_gamma", "slider": "CRTgamma" } + ], + "input": [ + { "sampler": "s_tex", "target": "internal2" } + ], + "output": "blur" + }, + { + "effect": "crt-geom/crt-geom-deluxe", + "name": "CRT", + "uniforms": [ + { "uniform": "curvature", "slider": "curvature" }, + { "uniform": "R", "slider": "R" }, + { "uniform": "d", "slider": "d" }, + { "uniform": "angle", "slider": "angle" }, + { "uniform": "cornersize", "slider": "cornersize" }, + { "uniform": "cornersmooth","slider": "cornersmooth" }, + { "uniform": "overscan", "slider": "overscan" }, + { "uniform": "aspect", "slider": "aspect" }, + { "uniform": "CRTgamma", "slider": "CRTgamma" }, + { "uniform": "monitorgamma","slider": "monitorgamma" }, + { "uniform": "aperture_strength","slider": "aperture_strength" }, + { "uniform": "halation", "slider": "halation" } + ], + + "input": [ + { "sampler": "mpass_texture", "target": "internal1" }, + { "sampler": "mask_texture", "texture": "bgfx/chains/crt-geom/aperture_1_2_bgr.png", "selection": "Shadow mask" }, + { "sampler": "blur_texture", "target": "blur" } + ], + + "output": "output" + } + ] +} diff --git a/bgfx/chains/crt-geom.json b/bgfx/chains/crt-geom.json new file mode 100644 index 00000000000..a8187319157 --- /dev/null +++ b/bgfx/chains/crt-geom.json @@ -0,0 +1,134 @@ +{ + "name": "CRT-geom", + "author": "cgwg", + "sliders": [ + { "type": "float", + "name": "aperture_strength", + "text": "Shadow mask strength", + "default": 0.4, + "max" : 1.0, + "min" : 0.0, + "step" : 0.05, + "format": "%1.2f", + "screen": "raster" }, + { "type": "float", + "name": "curvature", + "text": "Enable curvature", + "default": 1.0, + "max" : 1.0, + "min" : 0.0, + "step" : 1.0, + "format": "%1.0f", + "screen": "raster" }, + { "type": "float", + "name": "R", + "text": "Radius of curvature", + "default": 3.5, + "max" : 10.0, + "min" : 0.5, + "step" : 0.1, + "format": "%1.1f", + "screen": "raster" }, + { "type": "float", + "name": "d", + "text": "Distance to screen", + "default": 2.0, + "max" : 10.0, + "min" : 0.1, + "step" : 0.1, + "format": "%1.1f", + "screen": "raster" }, + { "type": "vec2", + "name": "angle", + "text": "Tilt ", + "default": [ 0.0,-0.05 ], + "max" : [ 1.0, 1.0 ], + "min" : [-1.0,-1.0 ], + "step" : 0.01, + "format": "%1.2f", + "screen": "raster" }, + { "type": "float", + "name": "cornersize", + "text": "Rounded corner size", + "default": 0.01, + "max" : 0.10, + "min" : 0.00, + "step" : 0.01, + "format": "%1.2f", + "screen": "raster" }, + { "type": "float", + "name": "cornersmooth", + "text": "Border smoothness", + "default": 1000, + "max" : 2000, + "min" : 100, + "step" : 100, + "format": "%1.0f", + "screen": "raster" }, + { "type": "vec2", + "name": "overscan", + "text": "Overscan ", + "default": [ 1.0, 1.0 ], + "max" : [ 1.2, 1.2 ], + "min" : [ 0.8, 0.8 ], + "step" : 0.02, + "format": "%1.2f", + "screen": "raster" }, + { "type": "float", + "name": "CRTgamma", + "text": "Gamma of simulated CRT", + "default": 2.4, + "max" : 4.0, + "min" : 0.7, + "step" : 0.05, + "format": "%1.2f", + "screen": "raster" }, + { "type": "float", + "name": "monitorgamma", + "text": "Gamma of output display", + "default": 2.2, + "max" : 4.0, + "min" : 0.7, + "step" : 0.05, + "format": "%1.2f", + "screen": "raster" }, + { "type": "vec2", + "name": "aspect", + "text": "Aspect ratio ", + "default": [ 1.0, 0.75 ], + "max" : [ 1.0, 1.0 ], + "min" : [ 0.3, 0.3 ], + "step" : 0.01, + "format": "%1.2f", + "screen": "raster" } + ], + "targets": [ + + ], + "passes": [ + { + "effect": "crt-geom/crt-geom", + "name": "CRT", + "uniforms": [ + { "uniform": "curvature", "slider": "curvature" }, + { "uniform": "R", "slider": "R" }, + { "uniform": "d", "slider": "d" }, + { "uniform": "angle", "slider": "angle" }, + { "uniform": "cornersize", "slider": "cornersize" }, + { "uniform": "cornersmooth","slider": "cornersmooth" }, + { "uniform": "overscan", "slider": "overscan" }, + { "uniform": "aspect", "slider": "aspect" }, + { "uniform": "CRTgamma", "slider": "CRTgamma" }, + { "uniform": "monitorgamma","slider": "monitorgamma" }, + { "uniform": "aperture_strength", "slider": "aperture_strength" } + ], + + "input": [ + { "sampler": "mpass_texture", "target": "screen" }, + { "sampler": "mask_texture", "texture": "bgfx/chains/crt-geom/aperture_1_2_bgr.png", "selection": "Shadow mask" } + ], + + "output": "output" + } + ] +} diff --git a/bgfx/effects/crt-geom/crt-geom-deluxe.json b/bgfx/effects/crt-geom/crt-geom-deluxe.json new file mode 100644 index 00000000000..f3168d5ff1d --- /dev/null +++ b/bgfx/effects/crt-geom/crt-geom-deluxe.json @@ -0,0 +1,43 @@ +{ + "blend": { + "equation": "add", + "srcColor": "1", + "dstColor": "0", + "srcAlpha": "1", + "dstAlpha": "0" + }, + "depth": { + "function": "always", + "writeenable": false + }, + "cull": { + "mode": "none" + }, + "write": { + "rgb": true, + "alpha": true + }, + "vertex": "chains/crt-geom/vs_crt-geom", + "fragment": "chains/crt-geom/fs_crt-geom-deluxe", + "uniforms": [ + { "name": "u_tex_size0", "type": "vec4", "values": [ 1.0, 1.0, 0.0, 0.0 ] }, + { "name": "u_tex_size1", "type": "vec4", "values": [ 1.0, 1.0, 0.0, 0.0 ] }, + { "name": "u_quad_dims", "type": "vec4", "values": [ 1.0, 1.0, 0.0, 0.0 ] }, + { "name": "u_rotation_type", "type": "vec4", "values": [ 1.0, 0.0, 0.0, 0.0 ] }, + { "name": "mpass_texture", "type": "int", "values": [ 0 ] }, + { "name": "mask_texture", "type": "int", "values": [ 1 ] }, + { "name": "blur_texture", "type": "int", "values": [ 1 ] }, + { "name": "curvature", "type": "vec4", "values": [ 1.0, 0.0, 0.0, 0.0 ] }, + { "name": "CRTgamma", "type": "vec4", "values": [ 2.4, 0.0, 0.0, 0.0 ] }, + { "name": "monitorgamma", "type": "vec4", "values": [ 2.2, 0.0, 0.0, 0.0 ] }, + { "name": "overscan", "type": "vec4", "values": [ 1.0, 1.0, 0.0, 0.0 ] }, + { "name": "aspect", "type": "vec4", "values": [ 1.0, 0.75,0.0, 0.0 ] }, + { "name": "d", "type": "vec4", "values": [ 2.0, 0.0, 0.0, 0.0 ] }, + { "name": "R", "type": "vec4", "values": [ 3.5, 0.0, 0.0, 0.0 ] }, + { "name": "angle", "type": "vec4", "values": [ 0.0,-0.05,0.0, 0.0 ] }, + { "name": "cornersize", "type": "vec4", "values": [ 0.01,0.0, 0.0, 0.0 ] }, + { "name": "cornersmooth", "type": "vec4", "values": [ 1000.0,0.0,0.0,0.0 ] }, + { "name": "aperture_strength", "type": "vec4", "values": [ 0.25,0.0,0.0,0.0 ] }, + { "name": "halation", "type": "vec4", "values": [ 0.1,0.0,0.0,0.0 ] } + ] +} diff --git a/bgfx/effects/crt-geom/crt-geom.json b/bgfx/effects/crt-geom/crt-geom.json new file mode 100644 index 00000000000..fe8e184a4ec --- /dev/null +++ b/bgfx/effects/crt-geom/crt-geom.json @@ -0,0 +1,41 @@ +{ + "blend": { + "equation": "add", + "srcColor": "1", + "dstColor": "0", + "srcAlpha": "1", + "dstAlpha": "0" + }, + "depth": { + "function": "always", + "writeenable": false + }, + "cull": { + "mode": "none" + }, + "write": { + "rgb": true, + "alpha": true + }, + "vertex": "chains/crt-geom/vs_crt-geom", + "fragment": "chains/crt-geom/fs_crt-geom", + "uniforms": [ + { "name": "u_tex_size0", "type": "vec4", "values": [ 1.0, 1.0, 0.0, 0.0 ] }, + { "name": "u_tex_size1", "type": "vec4", "values": [ 1.0, 1.0, 0.0, 0.0 ] }, + { "name": "u_quad_dims", "type": "vec4", "values": [ 1.0, 1.0, 0.0, 0.0 ] }, + { "name": "u_rotation_type", "type": "vec4", "values": [ 1.0, 0.0, 0.0, 0.0 ] }, + { "name": "mpass_texture", "type": "int", "values": [ 0 ] }, + { "name": "mask_texture", "type": "int", "values": [ 1 ] }, + { "name": "curvature", "type": "vec4", "values": [ 1.0, 0.0, 0.0, 0.0 ] }, + { "name": "CRTgamma", "type": "vec4", "values": [ 2.4, 0.0, 0.0, 0.0 ] }, + { "name": "monitorgamma", "type": "vec4", "values": [ 2.2, 0.0, 0.0, 0.0 ] }, + { "name": "overscan", "type": "vec4", "values": [ 1.0, 1.0, 0.0, 0.0 ] }, + { "name": "aspect", "type": "vec4", "values": [ 1.0, 0.75,0.0, 0.0 ] }, + { "name": "d", "type": "vec4", "values": [ 2.0, 0.0, 0.0, 0.0 ] }, + { "name": "R", "type": "vec4", "values": [ 3.5, 0.0, 0.0, 0.0 ] }, + { "name": "angle", "type": "vec4", "values": [ 0.0,-0.05,0.0, 0.0 ] }, + { "name": "cornersize", "type": "vec4", "values": [ 0.01,0.0, 0.0, 0.0 ] }, + { "name": "cornersmooth", "type": "vec4", "values": [ 1000.0,0.0,0.0,0.0 ] }, + { "name": "aperture_strength", "type": "vec4", "values": [ 0.25,0.0,0.0,0.0 ] } + ] +} diff --git a/bgfx/effects/crt-geom/gaussx.json b/bgfx/effects/crt-geom/gaussx.json new file mode 100644 index 00000000000..28e9cff1b87 --- /dev/null +++ b/bgfx/effects/crt-geom/gaussx.json @@ -0,0 +1,29 @@ +{ + "blend": { + "equation": "add", + "srcColor": "1", + "dstColor": "0", + "srcAlpha": "1", + "dstAlpha": "0" + }, + "depth": { + "function": "always", + "writeenable": false + }, + "cull": { + "mode": "none" + }, + "write": { + "rgb": true, + "alpha": true + }, + "vertex": "chains/crt-geom/vs_gaussx", + "fragment": "chains/crt-geom/fs_gaussx", + "uniforms": [ + { "name": "s_tex", "type": "int", "values": [ 0 ] }, + { "name": "u_tex_size0", "type": "vec4", "values": [ 1.0, 1.0, 0.0, 0.0 ] }, + { "name": "u_width", "type": "vec4", "values": [ 2.0, 0.0, 0.0, 0.0 ] }, + { "name": "u_aspect", "type": "vec4", "values": [ 1.0,0.75, 0.0, 0.0 ] }, + { "name": "u_gamma", "type": "vec4", "values": [ 2.2, 0.0, 0.0, 0.0 ] } + ] +} diff --git a/bgfx/effects/crt-geom/gaussy.json b/bgfx/effects/crt-geom/gaussy.json new file mode 100644 index 00000000000..65e324f0930 --- /dev/null +++ b/bgfx/effects/crt-geom/gaussy.json @@ -0,0 +1,29 @@ +{ + "blend": { + "equation": "add", + "srcColor": "1", + "dstColor": "0", + "srcAlpha": "1", + "dstAlpha": "0" + }, + "depth": { + "function": "always", + "writeenable": false + }, + "cull": { + "mode": "none" + }, + "write": { + "rgb": true, + "alpha": true + }, + "vertex": "chains/crt-geom/vs_gaussy", + "fragment": "chains/crt-geom/fs_gaussy", + "uniforms": [ + { "name": "s_tex", "type": "int", "values": [ 0 ] }, + { "name": "u_tex_size0", "type": "vec4", "values": [ 1.0, 1.0, 0.0, 0.0 ] }, + { "name": "u_width", "type": "vec4", "values": [ 2.0, 0.0, 0.0, 0.0 ] }, + { "name": "u_aspect", "type": "vec4", "values": [ 1.0,0.75, 0.0, 0.0 ] }, + { "name": "u_gamma", "type": "vec4", "values": [ 2.2, 0.0, 0.0, 0.0 ] } + ] +} diff --git a/bgfx/effects/crt-geom/phosphor_apply.json b/bgfx/effects/crt-geom/phosphor_apply.json new file mode 100644 index 00000000000..4353d0d9765 --- /dev/null +++ b/bgfx/effects/crt-geom/phosphor_apply.json @@ -0,0 +1,29 @@ +{ + "blend": { + "equation": "add", + "srcColor": "1", + "dstColor": "0", + "srcAlpha": "1", + "dstAlpha": "0" + }, + "depth": { + "function": "always", + "writeenable": false + }, + "cull": { + "mode": "none" + }, + "write": { + "rgb": true, + "alpha": true + }, + "vertex": "chains/crt-geom/vs_phosphor_apply", + "fragment": "chains/crt-geom/fs_phosphor_apply", + "uniforms": [ + { "name": "s_screen", "type": "int", "values": [ 0 ] }, + { "name": "s_phosphor", "type": "int", "values": [ 1 ] }, + { "name": "u_phosphor_power", "type": "vec4", "values": [ 1.3, 0.0, 0.0, 0.0 ] }, + { "name": "u_phosphor_amplitude","type": "vec4", "values": [ 0.2, 0.0, 0.0, 0.0 ] }, + { "name": "u_gamma", "type": "vec4", "values": [ 2.2, 0.0, 0.0, 0.0 ] } + ] +} diff --git a/bgfx/effects/crt-geom/phosphor_update.json b/bgfx/effects/crt-geom/phosphor_update.json new file mode 100644 index 00000000000..c1808c8fb81 --- /dev/null +++ b/bgfx/effects/crt-geom/phosphor_update.json @@ -0,0 +1,29 @@ +{ + "blend": { + "equation": "add", + "srcColor": "1", + "dstColor": "0", + "srcAlpha": "1", + "dstAlpha": "0" + }, + "depth": { + "function": "always", + "writeenable": false + }, + "cull": { + "mode": "none" + }, + "write": { + "rgb": true, + "alpha": true + }, + "vertex": "chains/crt-geom/vs_phosphor_update", + "fragment": "chains/crt-geom/fs_phosphor_update", + "uniforms": [ + { "name": "s_screen", "type": "int", "values": [ 0 ] }, + { "name": "s_phosphor", "type": "int", "values": [ 1 ] }, + { "name": "u_phosphor_power", "type": "vec4", "values": [ 1.3, 0.0, 0.0, 0.0 ] }, + { "name": "u_phosphor_amplitude","type": "vec4", "values": [ 0.2, 0.0, 0.0, 0.0 ] }, + { "name": "u_gamma", "type": "vec4", "values": [ 2.2, 0.0, 0.0, 0.0 ] } + ] +} diff --git a/bgfx/shaders/dx11/chains/crt-geom/fs_crt-geom-deluxe.bin b/bgfx/shaders/dx11/chains/crt-geom/fs_crt-geom-deluxe.bin Binary files differnew file mode 100644 index 00000000000..1e91cd50893 --- /dev/null +++ b/bgfx/shaders/dx11/chains/crt-geom/fs_crt-geom-deluxe.bin diff --git a/bgfx/shaders/dx11/chains/crt-geom/fs_crt-geom.bin b/bgfx/shaders/dx11/chains/crt-geom/fs_crt-geom.bin Binary files differnew file mode 100644 index 00000000000..4d4fa77e41f --- /dev/null +++ b/bgfx/shaders/dx11/chains/crt-geom/fs_crt-geom.bin diff --git a/bgfx/shaders/dx11/chains/crt-geom/fs_gaussx.bin b/bgfx/shaders/dx11/chains/crt-geom/fs_gaussx.bin Binary files differnew file mode 100644 index 00000000000..c6f2bb3cbe7 --- /dev/null +++ b/bgfx/shaders/dx11/chains/crt-geom/fs_gaussx.bin diff --git a/bgfx/shaders/dx11/chains/crt-geom/fs_gaussy.bin b/bgfx/shaders/dx11/chains/crt-geom/fs_gaussy.bin Binary files differnew file mode 100644 index 00000000000..d0e3b33f647 --- /dev/null +++ b/bgfx/shaders/dx11/chains/crt-geom/fs_gaussy.bin diff --git a/bgfx/shaders/dx11/chains/crt-geom/fs_phosphor_apply.bin b/bgfx/shaders/dx11/chains/crt-geom/fs_phosphor_apply.bin Binary files differnew file mode 100644 index 00000000000..51f7110a4dc --- /dev/null +++ b/bgfx/shaders/dx11/chains/crt-geom/fs_phosphor_apply.bin diff --git a/bgfx/shaders/dx11/chains/crt-geom/fs_phosphor_update.bin b/bgfx/shaders/dx11/chains/crt-geom/fs_phosphor_update.bin Binary files differnew file mode 100644 index 00000000000..ac5014661b4 --- /dev/null +++ b/bgfx/shaders/dx11/chains/crt-geom/fs_phosphor_update.bin diff --git a/bgfx/shaders/dx11/chains/crt-geom/vs_crt-geom.bin b/bgfx/shaders/dx11/chains/crt-geom/vs_crt-geom.bin Binary files differnew file mode 100644 index 00000000000..00f36ed736d --- /dev/null +++ b/bgfx/shaders/dx11/chains/crt-geom/vs_crt-geom.bin diff --git a/bgfx/shaders/dx11/chains/crt-geom/vs_gaussx.bin b/bgfx/shaders/dx11/chains/crt-geom/vs_gaussx.bin Binary files differnew file mode 100644 index 00000000000..fb6dc5e2aa2 --- /dev/null +++ b/bgfx/shaders/dx11/chains/crt-geom/vs_gaussx.bin diff --git a/bgfx/shaders/dx11/chains/crt-geom/vs_gaussy.bin b/bgfx/shaders/dx11/chains/crt-geom/vs_gaussy.bin Binary files differnew file mode 100644 index 00000000000..a0acbeb0800 --- /dev/null +++ b/bgfx/shaders/dx11/chains/crt-geom/vs_gaussy.bin diff --git a/bgfx/shaders/dx11/chains/crt-geom/vs_phosphor_apply.bin b/bgfx/shaders/dx11/chains/crt-geom/vs_phosphor_apply.bin Binary files differnew file mode 100644 index 00000000000..6797da332d9 --- /dev/null +++ b/bgfx/shaders/dx11/chains/crt-geom/vs_phosphor_apply.bin diff --git a/bgfx/shaders/dx11/chains/crt-geom/vs_phosphor_update.bin b/bgfx/shaders/dx11/chains/crt-geom/vs_phosphor_update.bin Binary files differnew file mode 100644 index 00000000000..6797da332d9 --- /dev/null +++ b/bgfx/shaders/dx11/chains/crt-geom/vs_phosphor_update.bin diff --git a/bgfx/shaders/dx9/chains/crt-geom/fs_crt-geom-deluxe.bin b/bgfx/shaders/dx9/chains/crt-geom/fs_crt-geom-deluxe.bin Binary files differnew file mode 100644 index 00000000000..5d1afeb8efa --- /dev/null +++ b/bgfx/shaders/dx9/chains/crt-geom/fs_crt-geom-deluxe.bin diff --git a/bgfx/shaders/dx9/chains/crt-geom/fs_crt-geom.bin b/bgfx/shaders/dx9/chains/crt-geom/fs_crt-geom.bin Binary files differnew file mode 100644 index 00000000000..0b63f55a585 --- /dev/null +++ b/bgfx/shaders/dx9/chains/crt-geom/fs_crt-geom.bin diff --git a/bgfx/shaders/dx9/chains/crt-geom/fs_gaussx.bin b/bgfx/shaders/dx9/chains/crt-geom/fs_gaussx.bin Binary files differnew file mode 100644 index 00000000000..f6ae9a161f3 --- /dev/null +++ b/bgfx/shaders/dx9/chains/crt-geom/fs_gaussx.bin diff --git a/bgfx/shaders/dx9/chains/crt-geom/fs_gaussy.bin b/bgfx/shaders/dx9/chains/crt-geom/fs_gaussy.bin Binary files differnew file mode 100644 index 00000000000..125ab63828d --- /dev/null +++ b/bgfx/shaders/dx9/chains/crt-geom/fs_gaussy.bin diff --git a/bgfx/shaders/dx9/chains/crt-geom/fs_phosphor_apply.bin b/bgfx/shaders/dx9/chains/crt-geom/fs_phosphor_apply.bin Binary files differnew file mode 100644 index 00000000000..b4b4839d8b5 --- /dev/null +++ b/bgfx/shaders/dx9/chains/crt-geom/fs_phosphor_apply.bin diff --git a/bgfx/shaders/dx9/chains/crt-geom/fs_phosphor_update.bin b/bgfx/shaders/dx9/chains/crt-geom/fs_phosphor_update.bin Binary files differnew file mode 100644 index 00000000000..384d2ddd48d --- /dev/null +++ b/bgfx/shaders/dx9/chains/crt-geom/fs_phosphor_update.bin diff --git a/bgfx/shaders/dx9/chains/crt-geom/vs_crt-geom.bin b/bgfx/shaders/dx9/chains/crt-geom/vs_crt-geom.bin Binary files differnew file mode 100644 index 00000000000..95d0b78bff4 --- /dev/null +++ b/bgfx/shaders/dx9/chains/crt-geom/vs_crt-geom.bin diff --git a/bgfx/shaders/dx9/chains/crt-geom/vs_gaussx.bin b/bgfx/shaders/dx9/chains/crt-geom/vs_gaussx.bin Binary files differnew file mode 100644 index 00000000000..878a259f8ab --- /dev/null +++ b/bgfx/shaders/dx9/chains/crt-geom/vs_gaussx.bin diff --git a/bgfx/shaders/dx9/chains/crt-geom/vs_gaussy.bin b/bgfx/shaders/dx9/chains/crt-geom/vs_gaussy.bin Binary files differnew file mode 100644 index 00000000000..3b1bbf6e556 --- /dev/null +++ b/bgfx/shaders/dx9/chains/crt-geom/vs_gaussy.bin diff --git a/bgfx/shaders/dx9/chains/crt-geom/vs_phosphor_apply.bin b/bgfx/shaders/dx9/chains/crt-geom/vs_phosphor_apply.bin Binary files differnew file mode 100644 index 00000000000..9f489e233ec --- /dev/null +++ b/bgfx/shaders/dx9/chains/crt-geom/vs_phosphor_apply.bin diff --git a/bgfx/shaders/dx9/chains/crt-geom/vs_phosphor_update.bin b/bgfx/shaders/dx9/chains/crt-geom/vs_phosphor_update.bin Binary files differnew file mode 100644 index 00000000000..9f489e233ec --- /dev/null +++ b/bgfx/shaders/dx9/chains/crt-geom/vs_phosphor_update.bin diff --git a/bgfx/shaders/gles/chains/crt-geom/fs_crt-geom-deluxe.bin b/bgfx/shaders/gles/chains/crt-geom/fs_crt-geom-deluxe.bin Binary files differnew file mode 100644 index 00000000000..166388d7a7c --- /dev/null +++ b/bgfx/shaders/gles/chains/crt-geom/fs_crt-geom-deluxe.bin diff --git a/bgfx/shaders/gles/chains/crt-geom/fs_crt-geom.bin b/bgfx/shaders/gles/chains/crt-geom/fs_crt-geom.bin Binary files differnew file mode 100644 index 00000000000..20ffe658385 --- /dev/null +++ b/bgfx/shaders/gles/chains/crt-geom/fs_crt-geom.bin diff --git a/bgfx/shaders/gles/chains/crt-geom/fs_gaussx.bin b/bgfx/shaders/gles/chains/crt-geom/fs_gaussx.bin Binary files differnew file mode 100644 index 00000000000..691c710fd68 --- /dev/null +++ b/bgfx/shaders/gles/chains/crt-geom/fs_gaussx.bin diff --git a/bgfx/shaders/gles/chains/crt-geom/fs_gaussy.bin b/bgfx/shaders/gles/chains/crt-geom/fs_gaussy.bin Binary files differnew file mode 100644 index 00000000000..988fc387f7d --- /dev/null +++ b/bgfx/shaders/gles/chains/crt-geom/fs_gaussy.bin diff --git a/bgfx/shaders/gles/chains/crt-geom/fs_phosphor_apply.bin b/bgfx/shaders/gles/chains/crt-geom/fs_phosphor_apply.bin Binary files differnew file mode 100644 index 00000000000..becc53dbbe3 --- /dev/null +++ b/bgfx/shaders/gles/chains/crt-geom/fs_phosphor_apply.bin diff --git a/bgfx/shaders/gles/chains/crt-geom/fs_phosphor_update.bin b/bgfx/shaders/gles/chains/crt-geom/fs_phosphor_update.bin Binary files differnew file mode 100644 index 00000000000..7e5f4e96765 --- /dev/null +++ b/bgfx/shaders/gles/chains/crt-geom/fs_phosphor_update.bin diff --git a/bgfx/shaders/gles/chains/crt-geom/vs_crt-geom.bin b/bgfx/shaders/gles/chains/crt-geom/vs_crt-geom.bin Binary files differnew file mode 100644 index 00000000000..d245ebe9b2a --- /dev/null +++ b/bgfx/shaders/gles/chains/crt-geom/vs_crt-geom.bin diff --git a/bgfx/shaders/gles/chains/crt-geom/vs_gaussx.bin b/bgfx/shaders/gles/chains/crt-geom/vs_gaussx.bin Binary files differnew file mode 100644 index 00000000000..f6c00846bc4 --- /dev/null +++ b/bgfx/shaders/gles/chains/crt-geom/vs_gaussx.bin diff --git a/bgfx/shaders/gles/chains/crt-geom/vs_gaussy.bin b/bgfx/shaders/gles/chains/crt-geom/vs_gaussy.bin Binary files differnew file mode 100644 index 00000000000..38d918884fb --- /dev/null +++ b/bgfx/shaders/gles/chains/crt-geom/vs_gaussy.bin diff --git a/bgfx/shaders/gles/chains/crt-geom/vs_phosphor_apply.bin b/bgfx/shaders/gles/chains/crt-geom/vs_phosphor_apply.bin Binary files differnew file mode 100644 index 00000000000..73a140fcc40 --- /dev/null +++ b/bgfx/shaders/gles/chains/crt-geom/vs_phosphor_apply.bin diff --git a/bgfx/shaders/gles/chains/crt-geom/vs_phosphor_update.bin b/bgfx/shaders/gles/chains/crt-geom/vs_phosphor_update.bin Binary files differnew file mode 100644 index 00000000000..73a140fcc40 --- /dev/null +++ b/bgfx/shaders/gles/chains/crt-geom/vs_phosphor_update.bin diff --git a/bgfx/shaders/glsl/chains/crt-geom/fs_crt-geom-deluxe.bin b/bgfx/shaders/glsl/chains/crt-geom/fs_crt-geom-deluxe.bin Binary files differnew file mode 100644 index 00000000000..0a54f384293 --- /dev/null +++ b/bgfx/shaders/glsl/chains/crt-geom/fs_crt-geom-deluxe.bin diff --git a/bgfx/shaders/glsl/chains/crt-geom/fs_crt-geom.bin b/bgfx/shaders/glsl/chains/crt-geom/fs_crt-geom.bin Binary files differnew file mode 100644 index 00000000000..7e03c559853 --- /dev/null +++ b/bgfx/shaders/glsl/chains/crt-geom/fs_crt-geom.bin diff --git a/bgfx/shaders/glsl/chains/crt-geom/fs_gaussx.bin b/bgfx/shaders/glsl/chains/crt-geom/fs_gaussx.bin Binary files differnew file mode 100644 index 00000000000..d83c7dea15d --- /dev/null +++ b/bgfx/shaders/glsl/chains/crt-geom/fs_gaussx.bin diff --git a/bgfx/shaders/glsl/chains/crt-geom/fs_gaussy.bin b/bgfx/shaders/glsl/chains/crt-geom/fs_gaussy.bin Binary files differnew file mode 100644 index 00000000000..0ab1151bba8 --- /dev/null +++ b/bgfx/shaders/glsl/chains/crt-geom/fs_gaussy.bin diff --git a/bgfx/shaders/glsl/chains/crt-geom/fs_phosphor_apply.bin b/bgfx/shaders/glsl/chains/crt-geom/fs_phosphor_apply.bin Binary files differnew file mode 100644 index 00000000000..5de0143b200 --- /dev/null +++ b/bgfx/shaders/glsl/chains/crt-geom/fs_phosphor_apply.bin diff --git a/bgfx/shaders/glsl/chains/crt-geom/fs_phosphor_update.bin b/bgfx/shaders/glsl/chains/crt-geom/fs_phosphor_update.bin Binary files differnew file mode 100644 index 00000000000..50034bc156c --- /dev/null +++ b/bgfx/shaders/glsl/chains/crt-geom/fs_phosphor_update.bin diff --git a/bgfx/shaders/glsl/chains/crt-geom/vs_crt-geom.bin b/bgfx/shaders/glsl/chains/crt-geom/vs_crt-geom.bin Binary files differnew file mode 100644 index 00000000000..4abb00b0de8 --- /dev/null +++ b/bgfx/shaders/glsl/chains/crt-geom/vs_crt-geom.bin diff --git a/bgfx/shaders/glsl/chains/crt-geom/vs_gaussx.bin b/bgfx/shaders/glsl/chains/crt-geom/vs_gaussx.bin Binary files differnew file mode 100644 index 00000000000..ebf8e8e4e87 --- /dev/null +++ b/bgfx/shaders/glsl/chains/crt-geom/vs_gaussx.bin diff --git a/bgfx/shaders/glsl/chains/crt-geom/vs_gaussy.bin b/bgfx/shaders/glsl/chains/crt-geom/vs_gaussy.bin Binary files differnew file mode 100644 index 00000000000..3461941df07 --- /dev/null +++ b/bgfx/shaders/glsl/chains/crt-geom/vs_gaussy.bin diff --git a/bgfx/shaders/glsl/chains/crt-geom/vs_phosphor_apply.bin b/bgfx/shaders/glsl/chains/crt-geom/vs_phosphor_apply.bin Binary files differnew file mode 100644 index 00000000000..a02931f846e --- /dev/null +++ b/bgfx/shaders/glsl/chains/crt-geom/vs_phosphor_apply.bin diff --git a/bgfx/shaders/glsl/chains/crt-geom/vs_phosphor_update.bin b/bgfx/shaders/glsl/chains/crt-geom/vs_phosphor_update.bin Binary files differnew file mode 100644 index 00000000000..a02931f846e --- /dev/null +++ b/bgfx/shaders/glsl/chains/crt-geom/vs_phosphor_update.bin diff --git a/bgfx/shaders/metal/chains/crt-geom/fs_crt-geom-deluxe.bin b/bgfx/shaders/metal/chains/crt-geom/fs_crt-geom-deluxe.bin Binary files differnew file mode 100644 index 00000000000..9b916b93043 --- /dev/null +++ b/bgfx/shaders/metal/chains/crt-geom/fs_crt-geom-deluxe.bin diff --git a/bgfx/shaders/metal/chains/crt-geom/fs_crt-geom.bin b/bgfx/shaders/metal/chains/crt-geom/fs_crt-geom.bin Binary files differnew file mode 100644 index 00000000000..cff6b7e6b6c --- /dev/null +++ b/bgfx/shaders/metal/chains/crt-geom/fs_crt-geom.bin diff --git a/bgfx/shaders/metal/chains/crt-geom/fs_gaussx.bin b/bgfx/shaders/metal/chains/crt-geom/fs_gaussx.bin Binary files differnew file mode 100644 index 00000000000..20840efaf16 --- /dev/null +++ b/bgfx/shaders/metal/chains/crt-geom/fs_gaussx.bin diff --git a/bgfx/shaders/metal/chains/crt-geom/fs_gaussy.bin b/bgfx/shaders/metal/chains/crt-geom/fs_gaussy.bin Binary files differnew file mode 100644 index 00000000000..b2487180322 --- /dev/null +++ b/bgfx/shaders/metal/chains/crt-geom/fs_gaussy.bin diff --git a/bgfx/shaders/metal/chains/crt-geom/fs_phosphor_apply.bin b/bgfx/shaders/metal/chains/crt-geom/fs_phosphor_apply.bin Binary files differnew file mode 100644 index 00000000000..2714075cdeb --- /dev/null +++ b/bgfx/shaders/metal/chains/crt-geom/fs_phosphor_apply.bin diff --git a/bgfx/shaders/metal/chains/crt-geom/fs_phosphor_update.bin b/bgfx/shaders/metal/chains/crt-geom/fs_phosphor_update.bin Binary files differnew file mode 100644 index 00000000000..9460ce0f08e --- /dev/null +++ b/bgfx/shaders/metal/chains/crt-geom/fs_phosphor_update.bin diff --git a/bgfx/shaders/metal/chains/crt-geom/vs_crt-geom.bin b/bgfx/shaders/metal/chains/crt-geom/vs_crt-geom.bin Binary files differnew file mode 100644 index 00000000000..f7d1102e36b --- /dev/null +++ b/bgfx/shaders/metal/chains/crt-geom/vs_crt-geom.bin diff --git a/bgfx/shaders/metal/chains/crt-geom/vs_gaussx.bin b/bgfx/shaders/metal/chains/crt-geom/vs_gaussx.bin Binary files differnew file mode 100644 index 00000000000..35c8a2f643d --- /dev/null +++ b/bgfx/shaders/metal/chains/crt-geom/vs_gaussx.bin diff --git a/bgfx/shaders/metal/chains/crt-geom/vs_gaussy.bin b/bgfx/shaders/metal/chains/crt-geom/vs_gaussy.bin Binary files differnew file mode 100644 index 00000000000..1f488205a1a --- /dev/null +++ b/bgfx/shaders/metal/chains/crt-geom/vs_gaussy.bin diff --git a/bgfx/shaders/metal/chains/crt-geom/vs_phosphor_apply.bin b/bgfx/shaders/metal/chains/crt-geom/vs_phosphor_apply.bin Binary files differnew file mode 100644 index 00000000000..b1ba0bf8201 --- /dev/null +++ b/bgfx/shaders/metal/chains/crt-geom/vs_phosphor_apply.bin diff --git a/bgfx/shaders/metal/chains/crt-geom/vs_phosphor_update.bin b/bgfx/shaders/metal/chains/crt-geom/vs_phosphor_update.bin Binary files differnew file mode 100644 index 00000000000..b1ba0bf8201 --- /dev/null +++ b/bgfx/shaders/metal/chains/crt-geom/vs_phosphor_update.bin diff --git a/src/osd/modules/render/bgfx/shaders/chains/crt-geom/fs_crt-geom-deluxe.sc b/src/osd/modules/render/bgfx/shaders/chains/crt-geom/fs_crt-geom-deluxe.sc new file mode 100644 index 00000000000..c5cfcbf2cdc --- /dev/null +++ b/src/osd/modules/render/bgfx/shaders/chains/crt-geom/fs_crt-geom-deluxe.sc @@ -0,0 +1,235 @@ +$input v_sinangle, v_cosangle, v_stretch, v_one, v_texCoord + +/* CRT shader + * + * Copyright (C) 2010-2016 cgwg, Themaister and DOLLS + * + * 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. + */ + +#include "common.sh" + +// Comment the next line to disable interpolation in linear gamma (and gain speed). +//#define LINEAR_PROCESSING + +// Enable 3x oversampling of the beam profile +#define OVERSAMPLE + +// Use the older, purely gaussian beam profile +#define USEGAUSSIAN + +// Macros. +#define FIX(c) max(abs(c), 1e-5) +#define PI 3.141592653589 + +SAMPLER2D(mpass_texture, 0); +SAMPLER2D(mask_texture, 1); +SAMPLER2D(blur_texture, 2); + +#ifdef LINEAR_PROCESSING +# define TEX2D(c) pow(texture2D(mpass_texture, (c)), vec4(CRTgamma)) +#else +# define TEX2D(c) texture2D(mpass_texture, (c)) +#endif + +// Enable screen curvature. +uniform vec4 curvature; + +uniform vec4 u_tex_size0; +uniform vec4 u_tex_size1; +uniform vec4 u_quad_dims; + +uniform vec4 aperture_strength; + +uniform vec4 CRTgamma; +uniform vec4 monitorgamma; + +uniform vec4 overscan; +uniform vec4 aspect; + +uniform vec4 d; +uniform vec4 R; + +uniform vec4 cornersize; +uniform vec4 cornersmooth; + +uniform vec4 halation; + +float intersect(vec2 xy , vec2 sinangle, vec2 cosangle) +{ + float A = dot(xy,xy)+d.x*d.x; + float B = 2.0*(R.x*(dot(xy,sinangle)-d.x*cosangle.x*cosangle.y)-d.x*d.x); + float C = d.x*d.x + 2.0*R.x*d.x*cosangle.x*cosangle.y; + return (-B-sqrt(B*B-4.0*A*C))/(2.0*A); +} + +vec2 bkwtrans(vec2 xy, vec2 sinangle, vec2 cosangle) +{ + float c = intersect(xy, sinangle, cosangle); + vec2 pt = vec2_splat(c)*xy; + pt -= vec2_splat(-R.x)*sinangle; + pt /= vec2_splat(R.x); + vec2 tang = sinangle/cosangle; + vec2 poc = pt/cosangle; + float A = dot(tang,tang)+1.0; + float B = -2.0*dot(poc,tang); + float C = dot(poc,poc)-1.0; + float a = (-B+sqrt(B*B-4.0*A*C))/(2.0*A); + vec2 uv = (pt-a*sinangle)/cosangle; + float r = FIX(R.x*acos(a)); + return uv*r/sin(r/R.x); +} + +vec2 transform(vec2 coord, vec3 stretch, vec2 sinangle, vec2 cosangle) +{ + coord = (coord-vec2_splat(0.5))*aspect.xy*stretch.z+stretch.xy; + return (bkwtrans(coord, sinangle, cosangle)/overscan.xy/aspect.xy+vec2_splat(0.5)); +} + +float corner(vec2 coord) +{ + coord = (coord - vec2_splat(0.5)) * overscan.xy + vec2_splat(0.5); + coord = min(coord, vec2_splat(1.0)-coord) * aspect.xy; + vec2 cdist = vec2_splat(cornersize.x); + coord = (cdist - min(coord,cdist)); + float dist = sqrt(dot(coord,coord)); + return clamp((max(cdist.x,1e-3)-dist)*cornersmooth.x,0.0, 1.0); +} + +// Calculate the influence of a scanline on the current pixel. +// +// 'distance' is the distance in texture coordinates from the current +// pixel to the scanline in question. +// 'color' is the colour of the scanline at the horizontal location of +// the current pixel. +vec4 scanlineWeights(float distance, vec4 color) +{ + // "wid" controls the width of the scanline beam, for each RGB channel + // The "weights" lines basically specify the formula that gives + // you the profile of the beam, i.e. the intensity as + // a function of distance from the vertical center of the + // scanline. In this case, it is gaussian if width=2, and + // becomes nongaussian for larger widths. Ideally this should + // be normalized so that the integral across the beam is + // independent of its width. That is, for a narrower beam + // "weights" should have a higher peak at the center of the + // scanline than for a wider beam. +#ifdef USEGAUSSIAN + vec4 wid = 0.3 + 0.1 * pow(color, vec4_splat(3.0)); + vec4 weights = vec4(distance / wid); + return 0.4 * exp(-weights * weights) / wid; +#else + vec4 wid = 2.0 + 2.0 * pow(color, vec4_splat(4.0)); + vec4 weights = vec4_splat(distance / 0.3); + return 1.4 * exp(-pow(weights * inversesqrt(0.5 * wid), wid)) / (0.6 + 0.2 * wid); +#endif +} + +void main() +{ + // Here's a helpful diagram to keep in mind while trying to + // understand the code: + // + // | | | | | + // ------------------------------- + // | | | | | + // | 01 | 11 | 21 | 31 | <-- current scanline + // | | @ | | | + // ------------------------------- + // | | | | | + // | 02 | 12 | 22 | 32 | <-- next scanline + // | | | | | + // ------------------------------- + // | | | | | + // + // Each character-cell represents a pixel on the output + // surface, "@" represents the current pixel (always somewhere + // in the bottom half of the current scan-line, or the top-half + // of the next scanline). The grid of lines represents the + // edges of the texels of the underlying texture. + + // Texture coordinates of the texel containing the active pixel. + vec2 xy; + if (curvature.x > 0.5) + xy = transform(v_texCoord, v_stretch, v_sinangle, v_cosangle); + else + xy = (v_texCoord-vec2_splat(0.5))/overscan.xy+vec2_splat(0.5); + vec2 xy0 = xy; + float cval = corner(xy); + + // Of all the pixels that are mapped onto the texel we are + // currently rendering, which pixel are we currently rendering? + vec2 ratio_scale = xy * u_tex_size0.xy - vec2_splat(0.5); + +#ifdef OVERSAMPLE + float filter = fwidth(ratio_scale.y); +#endif + vec2 uv_ratio = fract(ratio_scale); + + // Snap to the center of the underlying texel. + xy = (floor(ratio_scale) + vec2_splat(0.5)) / u_tex_size0.xy; + + // Calculate Lanczos scaling coefficients describing the effect + // of various neighbour texels in a scanline on the current + // pixel. + vec4 coeffs = PI * vec4(1.0 + uv_ratio.x, uv_ratio.x, 1.0 - uv_ratio.x, 2.0 - uv_ratio.x); + + // Prevent division by zero. + coeffs = FIX(coeffs); + + // Lanczos2 kernel. + coeffs = 2.0 * sin(coeffs) * sin(coeffs / 2.0) / (coeffs * coeffs); + + // Normalize. + coeffs /= dot(coeffs, vec4_splat(1.0)); + + // Calculate the effective colour of the current and next + // scanlines at the horizontal location of the current pixel, + // using the Lanczos coefficients above. + vec4 col = clamp(TEX2D(xy + vec2(-v_one.x, 0.0))*coeffs.x + + TEX2D(xy)*coeffs.y + + TEX2D(xy +vec2(v_one.x, 0.0))*coeffs.z + + TEX2D(xy + vec2(2.0 * v_one.x, 0.0))*coeffs.w , 0.0, 1.0); + + vec4 col2 = clamp(TEX2D(xy + vec2(-v_one.x, v_one.y))*coeffs.x + + TEX2D(xy + vec2(0.0, v_one.y))*coeffs.y + + TEX2D(xy + v_one)*coeffs.z + + TEX2D(xy + vec2(2.0 * v_one.x, v_one.y))*coeffs.w , 0.0, 1.0); + + +#ifndef LINEAR_PROCESSING + col = pow(col , vec4_splat(CRTgamma.x)); + col2 = pow(col2, vec4_splat(CRTgamma.x)); +#endif + + // Calculate the influence of the current and next scanlines on + // the current pixel. + vec4 weights = scanlineWeights(uv_ratio.y, col); + vec4 weights2 = scanlineWeights(1.0 - uv_ratio.y, col2); +#ifdef OVERSAMPLE + uv_ratio.y =uv_ratio.y+1.0/3.0*filter; + weights = (weights+scanlineWeights(uv_ratio.y, col))/3.0; + weights2=(weights2+scanlineWeights(abs(1.0-uv_ratio.y), col2))/3.0; + uv_ratio.y =uv_ratio.y-2.0/3.0*filter; + weights=weights+scanlineWeights(abs(uv_ratio.y), col)/3.0; + weights2=weights2+scanlineWeights(abs(1.0-uv_ratio.y), col2)/3.0; +#endif + vec3 mul_res = (col * weights + col2 * weights2).rgb; + + // halation and corners + vec3 blur = pow(texture2D(blur_texture,xy0).rgb, vec3_splat(CRTgamma.x)); + mul_res = mix(mul_res, blur, halation.x) * vec3_splat(cval); + + // Convert the image gamma for display on our output device. + mul_res = pow(mul_res, vec3_splat(1.0 / monitorgamma.x)); + + // Shadow mask + xy = v_texCoord.xy * u_quad_dims.xy / u_tex_size1.xy; + vec3 mask = texture2D(mask_texture, xy).rgb; + mask = mix(vec3_splat(1.0), mask, aperture_strength.x); + + gl_FragColor = vec4(mul_res*mask, col.a); +} diff --git a/src/osd/modules/render/bgfx/shaders/chains/crt-geom/fs_crt-geom.sc b/src/osd/modules/render/bgfx/shaders/chains/crt-geom/fs_crt-geom.sc new file mode 100644 index 00000000000..919ba46d0ab --- /dev/null +++ b/src/osd/modules/render/bgfx/shaders/chains/crt-geom/fs_crt-geom.sc @@ -0,0 +1,227 @@ +$input v_sinangle, v_cosangle, v_stretch, v_one, v_texCoord + +/* CRT shader + * + * Copyright (C) 2010-2016 cgwg, Themaister and DOLLS + * + * 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. + */ + +#include "common.sh" + +// Comment the next line to disable interpolation in linear gamma (and gain speed). +//#define LINEAR_PROCESSING + +// Enable 3x oversampling of the beam profile +#define OVERSAMPLE + +// Use the older, purely gaussian beam profile +#define USEGAUSSIAN + +// Macros. +#define FIX(c) max(abs(c), 1e-5) +#define PI 3.141592653589 + +SAMPLER2D(mpass_texture, 0); +SAMPLER2D(mask_texture, 1); +#ifdef LINEAR_PROCESSING +# define TEX2D(c) pow(texture2D(mpass_texture, (c)), vec4(CRTgamma)) +#else +# define TEX2D(c) texture2D(mpass_texture, (c)) +#endif + +// Enable screen curvature. +uniform vec4 curvature; + +uniform vec4 u_tex_size0; +uniform vec4 u_tex_size1; +uniform vec4 u_quad_dims; + +uniform vec4 aperture_strength; + +uniform vec4 CRTgamma; +uniform vec4 monitorgamma; + +uniform vec4 overscan; +uniform vec4 aspect; + +uniform vec4 d; +uniform vec4 R; + +uniform vec4 cornersize; +uniform vec4 cornersmooth; + +float intersect(vec2 xy , vec2 sinangle, vec2 cosangle) +{ + float A = dot(xy,xy)+d.x*d.x; + float B = 2.0*(R.x*(dot(xy,sinangle)-d.x*cosangle.x*cosangle.y)-d.x*d.x); + float C = d.x*d.x + 2.0*R.x*d.x*cosangle.x*cosangle.y; + return (-B-sqrt(B*B-4.0*A*C))/(2.0*A); +} + +vec2 bkwtrans(vec2 xy, vec2 sinangle, vec2 cosangle) +{ + float c = intersect(xy, sinangle, cosangle); + vec2 pt = vec2_splat(c)*xy; + pt -= vec2_splat(-R.x)*sinangle; + pt /= vec2_splat(R.x); + vec2 tang = sinangle/cosangle; + vec2 poc = pt/cosangle; + float A = dot(tang,tang)+1.0; + float B = -2.0*dot(poc,tang); + float C = dot(poc,poc)-1.0; + float a = (-B+sqrt(B*B-4.0*A*C))/(2.0*A); + vec2 uv = (pt-a*sinangle)/cosangle; + float r = FIX(R.x*acos(a)); + return uv*r/sin(r/R.x); +} + +vec2 transform(vec2 coord, vec3 stretch, vec2 sinangle, vec2 cosangle) +{ + coord = (coord-vec2_splat(0.5))*aspect.xy*stretch.z+stretch.xy; + return (bkwtrans(coord, sinangle, cosangle)/overscan.xy/aspect.xy+vec2_splat(0.5)); +} + +float corner(vec2 coord) +{ + coord = (coord - vec2_splat(0.5)) * overscan.xy + vec2_splat(0.5); + coord = min(coord, vec2_splat(1.0)-coord) * aspect.xy; + vec2 cdist = vec2_splat(cornersize.x); + coord = (cdist - min(coord,cdist)); + float dist = sqrt(dot(coord,coord)); + return clamp((max(cdist.x,1e-3)-dist)*cornersmooth.x,0.0, 1.0); +} + +// Calculate the influence of a scanline on the current pixel. +// +// 'distance' is the distance in texture coordinates from the current +// pixel to the scanline in question. +// 'color' is the colour of the scanline at the horizontal location of +// the current pixel. +vec4 scanlineWeights(float distance, vec4 color) +{ + // "wid" controls the width of the scanline beam, for each RGB channel + // The "weights" lines basically specify the formula that gives + // you the profile of the beam, i.e. the intensity as + // a function of distance from the vertical center of the + // scanline. In this case, it is gaussian if width=2, and + // becomes nongaussian for larger widths. Ideally this should + // be normalized so that the integral across the beam is + // independent of its width. That is, for a narrower beam + // "weights" should have a higher peak at the center of the + // scanline than for a wider beam. +#ifdef USEGAUSSIAN + vec4 wid = 0.3 + 0.1 * pow(color, vec4_splat(3.0)); + vec4 weights = vec4(distance / wid); + return 0.4 * exp(-weights * weights) / wid; +#else + vec4 wid = 2.0 + 2.0 * pow(color, vec4_splat(4.0)); + vec4 weights = vec4_splat(distance / 0.3); + return 1.4 * exp(-pow(weights * inversesqrt(0.5 * wid), wid)) / (0.6 + 0.2 * wid); +#endif +} + +void main() +{ + // Here's a helpful diagram to keep in mind while trying to + // understand the code: + // + // | | | | | + // ------------------------------- + // | | | | | + // | 01 | 11 | 21 | 31 | <-- current scanline + // | | @ | | | + // ------------------------------- + // | | | | | + // | 02 | 12 | 22 | 32 | <-- next scanline + // | | | | | + // ------------------------------- + // | | | | | + // + // Each character-cell represents a pixel on the output + // surface, "@" represents the current pixel (always somewhere + // in the bottom half of the current scan-line, or the top-half + // of the next scanline). The grid of lines represents the + // edges of the texels of the underlying texture. + + // Texture coordinates of the texel containing the active pixel. + vec2 xy; + if (curvature.x > 0.5) + xy = transform(v_texCoord, v_stretch, v_sinangle, v_cosangle); + else + xy = (v_texCoord-vec2_splat(0.5))/overscan.xy+vec2_splat(0.5); + float cval = corner(xy); + + // Of all the pixels that are mapped onto the texel we are + // currently rendering, which pixel are we currently rendering? + vec2 ratio_scale = xy * u_tex_size0.xy - vec2_splat(0.5); + +#ifdef OVERSAMPLE + float filter = fwidth(ratio_scale.y); +#endif + vec2 uv_ratio = fract(ratio_scale); + + // Snap to the center of the underlying texel. + xy = (floor(ratio_scale) + vec2_splat(0.5)) / u_tex_size0.xy; + + // Calculate Lanczos scaling coefficients describing the effect + // of various neighbour texels in a scanline on the current + // pixel. + vec4 coeffs = PI * vec4(1.0 + uv_ratio.x, uv_ratio.x, 1.0 - uv_ratio.x, 2.0 - uv_ratio.x); + + // Prevent division by zero. + coeffs = FIX(coeffs); + + // Lanczos2 kernel. + coeffs = 2.0 * sin(coeffs) * sin(coeffs / 2.0) / (coeffs * coeffs); + + // Normalize. + coeffs /= dot(coeffs, vec4_splat(1.0)); + + // Calculate the effective colour of the current and next + // scanlines at the horizontal location of the current pixel, + // using the Lanczos coefficients above. + vec4 col = clamp(TEX2D(xy + vec2(-v_one.x, 0.0))*coeffs.x + + TEX2D(xy)*coeffs.y + + TEX2D(xy +vec2(v_one.x, 0.0))*coeffs.z + + TEX2D(xy + vec2(2.0 * v_one.x, 0.0))*coeffs.w , 0.0, 1.0); + + vec4 col2 = clamp(TEX2D(xy + vec2(-v_one.x, v_one.y))*coeffs.x + + TEX2D(xy + vec2(0.0, v_one.y))*coeffs.y + + TEX2D(xy + v_one)*coeffs.z + + TEX2D(xy + vec2(2.0 * v_one.x, v_one.y))*coeffs.w , 0.0, 1.0); + + +#ifndef LINEAR_PROCESSING + col = pow(col , vec4_splat(CRTgamma.x)); + col2 = pow(col2, vec4_splat(CRTgamma.x)); +#endif + + // Calculate the influence of the current and next scanlines on + // the current pixel. + vec4 weights = scanlineWeights(uv_ratio.y, col); + vec4 weights2 = scanlineWeights(1.0 - uv_ratio.y, col2); +#ifdef OVERSAMPLE + uv_ratio.y =uv_ratio.y+1.0/3.0*filter; + weights = (weights+scanlineWeights(uv_ratio.y, col))/3.0; + weights2=(weights2+scanlineWeights(abs(1.0-uv_ratio.y), col2))/3.0; + uv_ratio.y =uv_ratio.y-2.0/3.0*filter; + weights=weights+scanlineWeights(abs(uv_ratio.y), col)/3.0; + weights2=weights2+scanlineWeights(abs(1.0-uv_ratio.y), col2)/3.0; +#endif + vec3 mul_res = (col * weights + col2 * weights2).rgb * vec3_splat(cval); + + // Convert the image gamma for display on our output device. + mul_res = pow(mul_res, vec3_splat(1.0 / monitorgamma.x)); + + // Color the texel. + + xy = v_texCoord.xy * u_quad_dims.xy / u_tex_size1.xy; + vec3 mask = texture2D(mask_texture, xy).rgb; + mask = mix(vec3_splat(1.0), mask, aperture_strength.x); + + gl_FragColor = vec4(mul_res*mask, col.a); +} diff --git a/src/osd/modules/render/bgfx/shaders/chains/crt-geom/fs_gaussx.sc b/src/osd/modules/render/bgfx/shaders/chains/crt-geom/fs_gaussx.sc new file mode 100644 index 00000000000..f45d1d5df81 --- /dev/null +++ b/src/osd/modules/render/bgfx/shaders/chains/crt-geom/fs_gaussx.sc @@ -0,0 +1,29 @@ +$input v_texCoord, v_coeffs + +#include "common.sh" + +uniform vec4 u_gamma; +uniform vec4 u_tex_size0; + +SAMPLER2D(s_tex, 0); +#define TEX2D(v) pow(texture2D(s_tex, v).rgb, vec3_splat(u_gamma.x)) + +void main() +{ + vec3 sum = vec3_splat(0.0); + float onex = 1.0/u_tex_size0.x; + + sum += TEX2D(v_texCoord + vec2(-4.0 * onex, 0.0)) * vec3_splat(v_coeffs.w); + sum += TEX2D(v_texCoord + vec2(-3.0 * onex, 0.0)) * vec3_splat(v_coeffs.z); + sum += TEX2D(v_texCoord + vec2(-2.0 * onex, 0.0)) * vec3_splat(v_coeffs.y); + sum += TEX2D(v_texCoord + vec2(-1.0 * onex, 0.0)) * vec3_splat(v_coeffs.x); + sum += TEX2D(v_texCoord); + sum += TEX2D(v_texCoord + vec2(+1.0 * onex, 0.0)) * vec3_splat(v_coeffs.x); + sum += TEX2D(v_texCoord + vec2(+2.0 * onex, 0.0)) * vec3_splat(v_coeffs.y); + sum += TEX2D(v_texCoord + vec2(+3.0 * onex, 0.0)) * vec3_splat(v_coeffs.z); + sum += TEX2D(v_texCoord + vec2(+4.0 * onex, 0.0)) * vec3_splat(v_coeffs.w); + + float norm = 1.0 / (1.0 + 2.0*(v_coeffs.x+v_coeffs.y+v_coeffs.z+v_coeffs.w)); + + gl_FragColor = vec4( pow(sum*vec3_splat(norm), vec3_splat(1.0/u_gamma.x)), 1.0 ); +} diff --git a/src/osd/modules/render/bgfx/shaders/chains/crt-geom/fs_gaussy.sc b/src/osd/modules/render/bgfx/shaders/chains/crt-geom/fs_gaussy.sc new file mode 100644 index 00000000000..107d1d7a5bb --- /dev/null +++ b/src/osd/modules/render/bgfx/shaders/chains/crt-geom/fs_gaussy.sc @@ -0,0 +1,29 @@ +$input v_texCoord, v_coeffs + +#include "common.sh" + +uniform vec4 u_gamma; +uniform vec4 u_tex_size0; + +SAMPLER2D(s_tex, 0); +#define TEX2D(v) pow(texture2D(s_tex, v).rgb, vec3_splat(u_gamma.x)) + +void main() +{ + vec3 sum = vec3_splat(0.0); + float oney = 1.0/u_tex_size0.y; + + sum += TEX2D(v_texCoord + vec2(0.0, -4.0 * oney)) * vec3_splat(v_coeffs.w); + sum += TEX2D(v_texCoord + vec2(0.0, -3.0 * oney)) * vec3_splat(v_coeffs.z); + sum += TEX2D(v_texCoord + vec2(0.0, -2.0 * oney)) * vec3_splat(v_coeffs.y); + sum += TEX2D(v_texCoord + vec2(0.0, -1.0 * oney)) * vec3_splat(v_coeffs.x); + sum += TEX2D(v_texCoord); + sum += TEX2D(v_texCoord + vec2(0.0, +1.0 * oney)) * vec3_splat(v_coeffs.x); + sum += TEX2D(v_texCoord + vec2(0.0, +2.0 * oney)) * vec3_splat(v_coeffs.y); + sum += TEX2D(v_texCoord + vec2(0.0, +3.0 * oney)) * vec3_splat(v_coeffs.z); + sum += TEX2D(v_texCoord + vec2(0.0, +4.0 * oney)) * vec3_splat(v_coeffs.w); + + float norm = 1.0 / (1.0 + 2.0*(v_coeffs.x+v_coeffs.y+v_coeffs.z+v_coeffs.w)); + + gl_FragColor = vec4( pow(sum*vec3_splat(norm), vec3_splat(1.0/u_gamma.x)), 1.0 ); +} diff --git a/src/osd/modules/render/bgfx/shaders/chains/crt-geom/fs_phosphor_apply.sc b/src/osd/modules/render/bgfx/shaders/chains/crt-geom/fs_phosphor_apply.sc new file mode 100644 index 00000000000..e70036084ff --- /dev/null +++ b/src/osd/modules/render/bgfx/shaders/chains/crt-geom/fs_phosphor_apply.sc @@ -0,0 +1,25 @@ +$input v_texCoord + +#include "common.sh" + +SAMPLER2D(s_screen, 0); +SAMPLER2D(s_phosphor, 1); + +uniform vec4 u_phosphor_power; +uniform vec4 u_phosphor_amplitude; +uniform vec4 u_gamma; + +void main() +{ + vec4 screen = texture2D(s_screen, v_texCoord); + vec4 phosphor = texture2D(s_phosphor, v_texCoord); + + vec3 cscrn = pow(screen.rgb, vec3_splat(u_gamma.x)); + vec3 cphos = pow(phosphor.rgb, vec3_splat(u_gamma.x)); + + cphos *= vec3_splat( u_phosphor_amplitude.x / pow(255.0*phosphor.a,u_phosphor_power.x) ); + + vec3 col = pow(cscrn + cphos, vec3_splat(1.0/u_gamma.x)); + + gl_FragColor = vec4(col, 1.0); +} diff --git a/src/osd/modules/render/bgfx/shaders/chains/crt-geom/fs_phosphor_update.sc b/src/osd/modules/render/bgfx/shaders/chains/crt-geom/fs_phosphor_update.sc new file mode 100644 index 00000000000..5215054b0db --- /dev/null +++ b/src/osd/modules/render/bgfx/shaders/chains/crt-geom/fs_phosphor_update.sc @@ -0,0 +1,24 @@ +$input v_texCoord + +#include "common.sh" + +SAMPLER2D(s_screen, 0); +SAMPLER2D(s_phosphor, 1); + +uniform vec4 u_phosphor_power; +uniform vec4 u_phosphor_amplitude; +uniform vec4 u_gamma; + +void main() +{ + vec4 screen = texture2D(s_screen, v_texCoord); + vec4 phosphor = texture2D(s_phosphor, v_texCoord); + + vec3 lum = vec3(0.299,0.587,0.114); + float bscrn = dot(pow(screen.rgb,vec3_splat(u_gamma.x)),lum); + float bphos = dot(pow(phosphor.rgb,vec3_splat(u_gamma.x)),lum); + //bscrn /= pow(1.0,u_phosphor_power.x); + bphos /= pow(1.0+255.0*phosphor.a,u_phosphor_power.x); + + gl_FragColor = ( bscrn > bphos ? vec4(screen.rgb,1.0/255.0) : vec4(phosphor.rgb,phosphor.a+1.0/255.0) ); +} diff --git a/src/osd/modules/render/bgfx/shaders/chains/crt-geom/varying.def.sc b/src/osd/modules/render/bgfx/shaders/chains/crt-geom/varying.def.sc new file mode 100644 index 00000000000..034ca88185b --- /dev/null +++ b/src/osd/modules/render/bgfx/shaders/chains/crt-geom/varying.def.sc @@ -0,0 +1,11 @@ +vec2 v_texCoord : TEXCOORD0 = vec2(0.0, 0.0); +vec3 v_stretch : TEXCOORD1 = vec3(0.0,0.0,0.0); +vec2 v_sinangle : TEXCOORD2 = vec2(0.0,0.0); +vec2 v_cosangle : TEXCOORD3 = vec2(0.0,0.0); +vec2 v_one : TEXCOORD4 = vec2(0.0,0.0); +vec4 v_coeffs : TEXCOORD5 = vec4(0.0,0.0,0.0,0.0); + +vec3 a_position : POSITION; +vec4 a_color0 : COLOR0; +vec2 a_texcoord0 : TEXCOORD0; + diff --git a/src/osd/modules/render/bgfx/shaders/chains/crt-geom/vs_crt-geom.sc b/src/osd/modules/render/bgfx/shaders/chains/crt-geom/vs_crt-geom.sc new file mode 100644 index 00000000000..cc3ed09aa14 --- /dev/null +++ b/src/osd/modules/render/bgfx/shaders/chains/crt-geom/vs_crt-geom.sc @@ -0,0 +1,96 @@ +$input a_position, a_texcoord0, a_color0 +$output v_sinangle, v_cosangle, v_stretch, v_one, v_texCoord + +/* CRT shader + * + * Copyright (C) 2010-2012 cgwg, Themaister and DOLLS + * + * 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. + */ + +#include "common.sh" + +uniform vec4 aspect; +uniform vec4 d; +uniform vec4 R; +uniform vec4 angle; + +uniform vec4 u_tex_size0; +uniform vec4 u_rotation_type; + +#define FIX(c) max(abs(c), 1e-5) + +float intersect(vec2 xy , vec2 sinangle, vec2 cosangle) +{ + float A = dot(xy,xy)+d.x*d.x; + float B = 2.0*(R.x*(dot(xy,sinangle)-d.x*cosangle.x*cosangle.y)-d.x*d.x); + float C = d.x*d.x + 2.0*R.x*d.x*cosangle.x*cosangle.y; + return (-B-sqrt(B*B-4.0*A*C))/(2.0*A); +} + +vec2 bkwtrans(vec2 xy, vec2 sinangle, vec2 cosangle) +{ + float c = intersect(xy, sinangle, cosangle); + vec2 pt = vec2_splat(c)*xy; + pt -= vec2_splat(-R.x)*sinangle; + pt /= vec2_splat(R.x); + vec2 tang = sinangle/cosangle; + vec2 poc = pt/cosangle; + float A = dot(tang,tang)+1.0; + float B = -2.0*dot(poc,tang); + float C = dot(poc,poc)-1.0; + float a = (-B+sqrt(B*B-4.0*A*C))/(2.0*A); + vec2 uv = (pt-a*sinangle)/cosangle; + float r = FIX(R.x*acos(a)); + return uv*r/sin(r/R.x); +} + +vec2 fwtrans(vec2 uv, vec2 sinangle, vec2 cosangle) +{ + float r = FIX(sqrt(dot(uv,uv))); + uv *= sin(r/R.x)/r; + float x = 1.0-cos(r/R.x); + float D = d.x/R.x + x*cosangle.x*cosangle.y+dot(uv,sinangle); + return d.x*(uv*cosangle-x*sinangle)/D; +} + +vec3 maxscale(vec2 sinangle, vec2 cosangle) +{ + vec2 c = bkwtrans(-R.x * sinangle / (1.0 + R.x/d.x*cosangle.x*cosangle.y), sinangle, cosangle); + vec2 a = vec2(0.5,0.5)*aspect.xy; + vec2 lo = vec2(fwtrans(vec2(-a.x,c.y), sinangle, cosangle).x, + fwtrans(vec2(c.x,-a.y), sinangle, cosangle).y)/aspect.xy; + vec2 hi = vec2(fwtrans(vec2(+a.x,c.y), sinangle, cosangle).x, + fwtrans(vec2(c.x,+a.y), sinangle, cosangle).y)/aspect.xy; + return vec3((hi+lo)*aspect.xy*0.5,max(hi.x-lo.x,hi.y-lo.y)); +} + + +void main() +{ + // Do the standard vertex processing. + gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0)); + v_texCoord = a_texcoord0; + + // Precalculate a bunch of useful values we'll need in the fragment + // shader. + vec2 ang; + // if (u_rotation_type.x < 0.5) + // ang = vec2(0.0,angle.x); + // else if (u_rotation_type.x < 1.5) + // ang = vec2(angle.x,0.0); + // else if (u_rotation_type.x < 2.5) + // ang = vec2(0.0,-angle.x); + // else + // ang = vec2(-angle.x,0.0); + ang = angle.xy; + v_sinangle = sin(ang); + v_cosangle = cos(ang); + v_stretch = maxscale(v_sinangle, v_cosangle); + + // The size of one texel, in texture-coordinates. + v_one = 1.0 / u_tex_size0.xy; +} diff --git a/src/osd/modules/render/bgfx/shaders/chains/crt-geom/vs_gaussx.sc b/src/osd/modules/render/bgfx/shaders/chains/crt-geom/vs_gaussx.sc new file mode 100644 index 00000000000..4bd5a57e3ef --- /dev/null +++ b/src/osd/modules/render/bgfx/shaders/chains/crt-geom/vs_gaussx.sc @@ -0,0 +1,18 @@ +$input a_position, a_texcoord0, a_color0 +$output v_texCoord, v_coeffs + +#include "common.sh" + +uniform vec4 u_tex_size0; +uniform vec4 u_width; +uniform vec4 u_aspect; + +void main() +{ + float wid = u_width.x*u_tex_size0.x/(320.*u_aspect.x);; + v_coeffs = exp(vec4(1.,4.,9.,16.)*vec4_splat(-1.0/wid/wid)); + + // Do the standard vertex processing. + gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0)); + v_texCoord = a_texcoord0; +} diff --git a/src/osd/modules/render/bgfx/shaders/chains/crt-geom/vs_gaussy.sc b/src/osd/modules/render/bgfx/shaders/chains/crt-geom/vs_gaussy.sc new file mode 100644 index 00000000000..3ff1e07f236 --- /dev/null +++ b/src/osd/modules/render/bgfx/shaders/chains/crt-geom/vs_gaussy.sc @@ -0,0 +1,18 @@ +$input a_position, a_texcoord0, a_color0 +$output v_texCoord, v_coeffs + +#include "common.sh" + +uniform vec4 u_tex_size0; +uniform vec4 u_width; +uniform vec4 u_aspect; + +void main() +{ + float wid = u_width.x*u_tex_size0.y/(320.*u_aspect.y); + v_coeffs = exp(vec4(1.,4.,9.,16.)*vec4_splat(-1.0/wid/wid)); + + // Do the standard vertex processing. + gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0)); + v_texCoord = a_texcoord0; +} diff --git a/src/osd/modules/render/bgfx/shaders/chains/crt-geom/vs_phosphor_apply.sc b/src/osd/modules/render/bgfx/shaders/chains/crt-geom/vs_phosphor_apply.sc new file mode 100644 index 00000000000..bdd09148403 --- /dev/null +++ b/src/osd/modules/render/bgfx/shaders/chains/crt-geom/vs_phosphor_apply.sc @@ -0,0 +1,11 @@ +$input a_position, a_texcoord0, a_color0 +$output v_texCoord + +#include "common.sh" + +void main() +{ + // Do the standard vertex processing. + gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0)); + v_texCoord = a_texcoord0; +} diff --git a/src/osd/modules/render/bgfx/shaders/chains/crt-geom/vs_phosphor_update.sc b/src/osd/modules/render/bgfx/shaders/chains/crt-geom/vs_phosphor_update.sc new file mode 100644 index 00000000000..bdd09148403 --- /dev/null +++ b/src/osd/modules/render/bgfx/shaders/chains/crt-geom/vs_phosphor_update.sc @@ -0,0 +1,11 @@ +$input a_position, a_texcoord0, a_color0 +$output v_texCoord + +#include "common.sh" + +void main() +{ + // Do the standard vertex processing. + gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0)); + v_texCoord = a_texcoord0; +} |