Polishing up BGFX shader system, nw

This commit is contained in:
therealmogminer@gmail.com 2016-03-18 03:21:34 +01:00
parent d7dc173df9
commit ea9e591a0c
112 changed files with 671 additions and 801 deletions

27
bgfx/chains/LICENSE Normal file
View File

@ -0,0 +1,27 @@
Copyright (c) 2016, Ryan Holtz and MAME Development Team
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of bsd3 nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

5
bgfx/chains/README.md Normal file
View File

@ -0,0 +1,5 @@
# **Tests** #
Cointains definitions for BGFX shader chains
Licensed under [The BSD 3-Clause License](http://opensource.org/licenses/BSD-3-Clause) by Ryan Holtz and MAME Development Team

View File

@ -19,42 +19,41 @@
{ "type": "color", "name": "grn_ratios", "text": "Green Output from ", "default": [ 0, 100, 0 ], "max": [ 200, 200, 200 ], "min": [ 0, 0, 0 ], "step": 1, "scale": 0.01, "format": "%1.2f", "screen": "raster" },
{ "type": "color", "name": "blu_ratios", "text": "Blue Output from ", "default": [ 0, 0, 100 ], "max": [ 200, 200, 200 ], "min": [ 0, 0, 0 ], "step": 1, "scale": 0.01, "format": "%1.2f", "screen": "raster" },
{ "type": "color", "name": "offset", "text": "Signal Offset, ", "default": [ 0, 0, 0 ], "max": [ 200, 200, 200 ], "min": [ 0, 0, 0 ], "step": 1, "scale": 0.01, "format": "%1.2f", "screen": "raster" },
{ "type": "color", "name": "scale", "text": "Signal Scale, ", "default": [ 100, 100, 100 ], "max": [ 200, 200, 200 ], "min": [ 0, 0, 0 ], "step": 1, "scale": 0.01, "format": "%1.2f", "screen": "raster" },
{ "type": "float", "name": "saturation", "text": "Color Saturation", "default": 100, "max": 400, "min": 0, "step": 1, "scale": 0.01, "format": "%1.2f", "screen": "raster" },
{ "type": "color", "name": "scale", "text": "Signal Scale, ", "default": [ 95, 95, 95 ], "max": [ 200, 200, 200 ], "min": [ 0, 0, 0 ], "step": 1, "scale": 0.01, "format": "%1.2f", "screen": "raster" },
{ "type": "float", "name": "saturation", "text": "Color Saturation", "default": 150, "max": 400, "min": 0, "step": 1, "scale": 0.01, "format": "%1.2f", "screen": "raster" },
{ "type": "vec2", "name": "converge_red", "text": "Red Convergence, ", "default": [ 0, 0 ], "max": [ 8000, 6000 ], "min": [ -8000, -6000 ], "step": 1, "scale": 0.1, "format": "%3.1f", "screen": "raster" },
{ "type": "vec2", "name": "converge_green", "text": "Green Convergence, ", "default": [ 0, 0 ], "max": [ 8000, 6000 ], "min": [ -8000, -6000 ], "step": 1, "scale": 0.1, "format": "%3.1f", "screen": "raster" },
{ "type": "vec2", "name": "converge_red", "text": "Red Convergence, ", "default": [ 5, 0 ], "max": [ 8000, 6000 ], "min": [ -8000, -6000 ], "step": 1, "scale": 0.1, "format": "%3.1f", "screen": "raster" },
{ "type": "vec2", "name": "converge_green", "text": "Green Convergence, ", "default": [ 0, 5 ], "max": [ 8000, 6000 ], "min": [ -8000, -6000 ], "step": 1, "scale": 0.1, "format": "%3.1f", "screen": "raster" },
{ "type": "vec2", "name": "converge_blue", "text": "Blue Convergence, ", "default": [ 0, 0 ], "max": [ 8000, 6000 ], "min": [ -8000, -6000 ], "step": 1, "scale": 0.1, "format": "%3.1f", "screen": "raster" },
{ "type": "vec2", "name": "radial_converge_red", "text": "Red Radial Convergence, ", "default": [ 0, 0 ], "max": [ 8000, 6000 ], "min": [ -8000, -6000 ], "step": 1, "scale": 0.1, "format": "%3.1f", "screen": "raster" },
{ "type": "vec2", "name": "radial_converge_green", "text": "Green Radial Convergence, ", "default": [ 0, 0 ], "max": [ 8000, 6000 ], "min": [ -8000, -6000 ], "step": 1, "scale": 0.1, "format": "%3.1f", "screen": "raster" },
{ "type": "vec2", "name": "radial_converge_blue", "text": "Blue Radial Convergence, ", "default": [ 0, 0 ], "max": [ 8000, 6000 ], "min": [ -8000, -6000 ], "step": 1, "scale": 0.1, "format": "%3.1f", "screen": "raster" },
{ "type": "vec2", "name": "defocus", "text": "Defocus, ", "default": [ 0, 0 ], "max": [ 500, 500 ], "min": [ 0, 0 ], "step": 1, "scale": 0.1, "format": "%2.1f", "screen": "crt" },
{ "type": "vec2", "name": "defocus", "text": "Defocus, ", "default": [ 5, 5 ], "max": [ 500, 500 ], "min": [ 0, 0 ], "step": 1, "scale": 0.1, "format": "%2.1f", "screen": "crt" },
{ "type": "color", "name": "phosphor", "text": "Phosphor Persistence, ", "default": [ 0, 0, 0 ], "max": [ 100, 100, 100 ], "min": [ 0, 0, 0 ], "step": 1, "scale": 0.01, "format": "%1.2f", "screen": "crt" },
{ "type": "color", "name": "phosphor", "text": "Phosphor Persistence, ", "default": [ 45, 45, 45 ], "max": [ 100, 100, 100 ], "min": [ 0, 0, 0 ], "step": 1, "scale": 0.01, "format": "%1.2f", "screen": "crt" },
{ "type": "float", "name": "scanline_alpha", "text": "Scanline Amount", "default": 0, "max": 100, "min": 0, "step": 1, "scale": 0.01, "format": "%1.2f", "screen": "crt" },
{ "type": "float", "name": "scanline_alpha", "text": "Scanline Amount", "default": 100, "max": 100, "min": 0, "step": 1, "scale": 0.01, "format": "%1.2f", "screen": "crt" },
{ "type": "float", "name": "scanline_scale", "text": "Overall Scanline Scale", "default": 100, "max": 400, "min": 0, "step": 1, "scale": 0.01, "format": "%1.2f", "screen": "crt" },
{ "type": "float", "name": "scanline_bright_scale", "text": "Scanline Brightness Scale", "default": 100, "max": 400, "min": 0, "step": 1, "scale": 0.01, "format": "%1.2f", "screen": "crt" },
{ "type": "float", "name": "scanline_bright_scale", "text": "Scanline Brightness Scale", "default": 200, "max": 400, "min": 0, "step": 1, "scale": 0.01, "format": "%1.2f", "screen": "crt" },
{ "type": "float", "name": "scanline_bright_offset", "text": "Scanline Brightness Offset", "default": 0, "max": 400, "min": 0, "step": 1, "scale": 0.01, "format": "%1.2f", "screen": "crt" },
{ "type": "float", "name": "scanline_jitter_amount", "text": "Scanline Jitter Amount", "default": 0, "max": 400, "min": 0, "step": 1, "scale": 0.01, "format": "%1.2f", "screen": "crt" },
{ "type": "float", "name": "scanline_height", "text": "Individual Scanline Scale", "default": 100, "max": 400, "min": 0, "step": 1, "scale": 0.01, "format": "%1.2f", "screen": "crt" },
{ "type": "float", "name": "shadow_alpha", "text": "Shadow Mask Amount", "default": 0, "max": 100, "min": 0, "step": 1, "scale": 0.01, "format": "%1.2f", "screen": "crt" },
{ "type": "vec2", "name": "shadow_count", "text": "Shadow Mask Pixel Count ", "default": [ 60, 40 ], "max": [ 400, 400 ], "min": [ 0, 0 ], "step": 1, "scale": 0.01, "format": "%1.2f", "screen": "crt" },
{ "type": "vec2", "name": "shadow_uv_size", "text": "Shadow Mask UV Size ", "default": [ 48, 64 ], "max": [ 256, 256 ], "min": [ 0, 0 ], "step": 1, "scale": 0.00390625, "format": "%1.7f", "screen": "crt" },
{ "type": "vec2", "name": "shadow_uv_offset", "text": "Shadow Mask UV Offset ", "default": [ 0, 0 ], "max": [ 256, 256 ], "min": [ 0, 0 ], "step": 1, "scale": 0.00390625, "format": "%1.7f", "screen": "crt" },
{ "type": "vec2", "name": "shadow_uv_size", "text": "Shadow Mask UV Size ", "default": [ 250, 333 ], "max": [ 1000, 1000 ], "min": [ 0, 0 ], "step": 1, "scale": 0.001, "format": "%1.4f", "screen": "crt" },
{ "type": "vec2", "name": "shadow_uv_offset", "text": "Shadow Mask UV Offset ", "default": [ 0, 0 ], "max": [ 1000, 1000 ], "min": [ 0, 0 ], "step": 1, "scale": 0.001, "format": "%1.4f", "screen": "crt" },
{ "type": "int_enum", "name": "shadow_tile_mode", "text": "Shadow Mask Tile Mode", "default": 0, "max": 1, "min": 0, "step": 1, "scale": 1.0, "format": "%s", "screen": "crt", "strings": [ "Screen", "Source" ] },
{ "type": "float", "name": "humbar_alpha", "text": "Hum Bar Amount", "default": 0, "max": 100, "min": 0, "step": 1, "scale": 0.01, "format": "%1.2f", "screen": "crt" },
{ "type": "float", "name": "humbar_alpha", "text": "Hum Bar Amount", "default": 5, "max": 100, "min": 0, "step": 1, "scale": 0.01, "format": "%1.2f", "screen": "crt" },
{ "type": "float", "name": "humbar_hertz_rate", "text": "Hum Bar Frequency", "default": 100, "max": 10000, "min": 0, "step": 1, "scale": 0.00001, "format": "%1.7f", "screen": "crt" },
{ "type": "color", "name": "floor", "text": "Signal Floor, ", "default": [ 0, 0, 0 ], "max": [ 100, 100, 100 ], "min": [ 0, 0, 0 ], "step": 1, "scale": 0.01, "format": "%1.2f", "screen": "crt" },
{ "type": "color", "name": "power", "text": "Signal Exponent, ", "default": [ 100, 100, 100 ], "max": [ 400, 400, 400 ], "min": [ 0, 0, 0 ], "step": 1, "scale": 0.01, "format": "%1.2f", "screen": "crt" },
{ "type": "color", "name": "floor", "text": "Signal Floor, ", "default": [ 5, 5, 5 ], "max": [ 100, 100, 100 ], "min": [ 0, 0, 0 ], "step": 1, "scale": 0.01, "format": "%1.2f", "screen": "crt" },
{ "type": "color", "name": "power", "text": "Signal Exponent, ", "default": [ 80, 80, 80 ], "max": [ 400, 400, 400 ], "min": [ 0, 0, 0 ], "step": 1, "scale": 0.01, "format": "%1.2f", "screen": "crt" },
{ "type": "float", "name": "curvature", "text": "Screen Curvature Amount", "default": 0, "max": 200, "min": 0, "step": 1, "scale": 0.01, "format": "%1.2f", "screen": "crt" },
{ "type": "float", "name": "round_corner", "text": "Rounded Corner Amount", "default": 0, "max": 200, "min": 0, "step": 1, "scale": 0.01, "format": "%1.2f", "screen": "crt" },
{ "type": "float", "name": "smooth_border", "text": "Smooth Border Amount", "default": 0, "max": 200, "min": 0, "step": 1, "scale": 0.01, "format": "%1.2f", "screen": "crt" },
{ "type": "float", "name": "vignetting", "text": "Vignetting Amount", "default": 0, "max": 200, "min": 0, "step": 1, "scale": 0.01, "format": "%1.2f", "screen": "crt" },
{ "type": "float", "name": "reflection", "text": "Reflection Amount", "default": 0, "max": 200, "min": 0, "step": 1, "scale": 0.01, "format": "%1.2f", "screen": "crt" }
{ "type": "float", "name": "curvature", "text": "Screen Curvature Amount", "default": 25, "max": 200, "min": 0, "step": 1, "scale": 0.01, "format": "%1.2f", "screen": "crt" },
{ "type": "float", "name": "round_corner", "text": "Rounded Corner Amount", "default": 20, "max": 200, "min": 0, "step": 1, "scale": 0.01, "format": "%1.2f", "screen": "crt" },
{ "type": "float", "name": "smooth_border", "text": "Smooth Border Amount", "default": 5, "max": 200, "min": 0, "step": 1, "scale": 0.01, "format": "%1.2f", "screen": "crt" },
{ "type": "float", "name": "vignetting", "text": "Vignetting Amount", "default": 20, "max": 200, "min": 0, "step": 1, "scale": 0.01, "format": "%1.2f", "screen": "crt" },
{ "type": "float", "name": "reflection", "text": "Reflection Amount", "default": 30, "max": 200, "min": 0, "step": 1, "scale": 0.01, "format": "%1.2f", "screen": "crt" }
],
"parameters": [
{ "name": "jitter", "type": "frame", "period": 2 },
@ -64,22 +63,27 @@
{
"name": "guest",
"mode": "guest",
"prescale": 1,
"bilinear": false,
"prescale": false,
"doublebuffer": true
},
{ "name": "native",
"mode": "native",
"prescale": 1,
{ "name": "internal",
"mode": "guest",
"prescale": true,
"doublebuffer": true
},
{ "name": "previous",
"mode": "guest",
"prescale": true,
"doublebuffer": true
},
{ "name": "screen",
"mode": "native",
"prescale": 1,
"doublebuffer": true
},
{ "name": "bloom",
"mode": "native",
"prescale": 1,
"mode": "guest",
"prescale": true,
"doublebuffer": true,
"pyramid": true
}
@ -101,7 +105,7 @@
{ "uniform": "u_jitter_amount", "parameter": "jitter" }
],
"input": [
{ "sampler": "DiffuseSampler", "texture": "screen" }
{ "sampler": "s_tex", "texture": "screen" }
],
"output": "guest"
},
@ -125,7 +129,7 @@
{ "uniform": "u_jitter_amount", "parameter": "jitter" }
],
"input": [
{ "sampler": "DiffuseSampler", "texture": "guest" }
{ "sampler": "s_tex", "texture": "guest" }
],
"output": "guest"
},
@ -154,7 +158,7 @@
{ "uniform": "u_saturation", "slider": "saturation" }
],
"input": [
{ "sampler": "DiffuseSampler", "texture": "guest" }
{ "sampler": "s_tex", "texture": "guest" }
],
"output": "guest"
},
@ -163,7 +167,7 @@
"input": [
{ "sampler": "s_tex", "texture": "guest" }
],
"output": "native"
"output": "internal"
},
{ "effect": "deconverge",
"name": "Deconvergence",
@ -185,9 +189,9 @@
{ "uniform": "u_radial_converge_blue", "slider": "radial_converge_blue" }
],
"input": [
{ "sampler": "DiffuseSampler", "texture": "native" }
{ "sampler": "s_tex", "texture": "internal" }
],
"output": "native"
"output": "internal"
},
{ "effect": "defocus",
"name": "Defocus Pass 1",
@ -199,9 +203,9 @@
{ "uniform": "u_defocus", "slider": "defocus" }
],
"input": [
{ "sampler": "DiffuseSampler", "texture": "native" }
{ "sampler": "s_tex", "texture": "internal" }
],
"output": "native"
"output": "internal"
},
{ "effect": "defocus",
"name": "Defocus Pass 2",
@ -213,9 +217,9 @@
{ "uniform": "u_defocus", "slider": "defocus" }
],
"input": [
{ "sampler": "DiffuseSampler", "texture": "native" }
{ "sampler": "s_tex", "texture": "internal" }
],
"output": "native"
"output": "internal"
},
{ "effect": "phosphor",
"name": "Phosphor Decay",
@ -228,10 +232,10 @@
{ "uniform": "u_phosphor", "slider": "phosphor" }
],
"input": [
{ "sampler": "s_tex", "texture": "native" },
{ "sampler": "s_tex", "texture": "internal" },
{ "sampler": "s_prev", "texture": "previous" }
],
"output": "native"
"output": "internal"
},
{ "effect": "phosphor",
"name": "Phosphor Store",
@ -244,8 +248,8 @@
{ "uniform": "u_phosphor", "slider": "phosphor" }
],
"input": [
{ "sampler": "s_tex", "texture": "native" },
{ "sampler": "s_prev", "texture": "native" }
{ "sampler": "s_tex", "texture": "internal" },
{ "sampler": "s_prev", "texture": "internal" }
],
"output": "previous"
},
@ -259,14 +263,12 @@
{ "type": "slider", "condition": "equal", "combine": "and", "name": "floor", "value": [ 0, 0, 0 ] },
{ "type": "slider", "condition": "equal", "combine": "and", "name": "power", "value": [ 0, 0, 0 ] }
],
"textures": [ { "name": "shadow" } ],
"uniforms": [
{ "uniform": "u_scanline_alpha", "slider": "scanline_alpha" },
{ "uniform": "u_scanline_scale", "slider": "scanline_scale" },
{ "uniform": "u_scanline_bright_scale", "slider": "scanline_bright_scale" },
{ "uniform": "u_scanline_bright_offset", "slider": "scanline_bright_offset" },
{ "uniform": "u_shadow_alpha", "slider": "shadow_alpha" },
{ "uniform": "u_shadow_count", "slider": "shadow_count" },
{ "uniform": "u_shadow_uv", "slider": "shadow_uv_size" },
{ "uniform": "u_shadow_uv_offset", "slider": "shadow_uv_offset" },
{ "uniform": "u_shadow_tile_mode", "slider": "shadow_tile_mode" },
@ -279,10 +281,10 @@
{ "uniform": "u_time", "parameter": "time" }
],
"input": [
{ "sampler": "DiffuseSampler", "texture": "native" },
{ "sampler": "ShadowSampler", "texture": "shadow" }
{ "sampler": "s_tex", "texture": "internal" },
{ "sampler": "s_shadow", "texture": "shadow" }
],
"output": "native"
"output": "internal"
},
{ "effect": "distortion",
"name": "Distortion Pass",
@ -302,10 +304,17 @@
{ "uniform": "u_reflection", "slider": "reflection" }
],
"input": [
{ "sampler": "DiffuseSampler", "texture": "native" }
{ "sampler": "s_tex", "texture": "internal" }
],
"output": "native"
"output": "internal"
},
{ "effect": "blit",
"name": "Final Downscale",
"input": [
{ "sampler": "s_tex", "texture": "internal" }
],
"output": "screen"
}
],
"output": "native"
"output": "screen"
}

View File

@ -1,115 +0,0 @@
{ "name": "Test Shader Chain",
"author": "Ryan Holtz",
"sliders": [
{ "type": "int_enum", "name": "adjustments", "text": "Enable Adjustments", "default": 0, "max": 1, "min": 0, "step": 1, "scale": 1.0, "format": "%s", "screen": "any", "strings": [ "Off", "On" ] },
{ "type": "float", "name": "ratio_amount", "text": "Ratio Amount", "default": 0, "max": 100, "min": 0, "step": 1, "scale": 0.01, "format": "%1.2f", "screen": "any" },
{ "type": "color", "name": "red_ratios", "text": "Color Matrix, Red from ", "default": [ 200, 0, 0 ], "max": [ 400, 400, 400 ], "min": [ 0, 0, 0 ], "step": 1, "scale": 0.005, "format": "%2.3f", "screen": "any" },
{ "type": "color", "name": "grn_ratios", "text": "Color Matrix, Green from ", "default": [ 0, 200, 0 ], "max": [ 400, 400, 400 ], "min": [ 0, 0, 0 ], "step": 1, "scale": 0.005, "format": "%2.3f", "screen": "any" },
{ "type": "color", "name": "blu_ratios", "text": "Color Matrix, Blue from ", "default": [ 0, 0, 200 ], "max": [ 400, 400, 400 ], "min": [ 0, 0, 0 ], "step": 1, "scale": 0.005, "format": "%2.3f", "screen": "any" },
{ "type": "color", "name": "tint", "text": "Tint ", "default": [ 100, 100, 100 ], "max": [ 100, 100, 100 ], "min": [ 0, 0, 0 ], "step": 1, "scale": 0.01, "format": "%1.2f", "screen": "any" },
{ "type": "color", "name": "phosphor", "text": "Phosphor Life, ", "default": [ 0, 0, 0 ], "max": [ 100, 100, 100 ], "min": [ 0, 0, 0 ], "step": 1, "scale": 0.01, "format": "%1.2f", "screen": "any" },
{ "type": "vec2", "name": "shift", "text": "Frame Shift ", "default": [ 0, 0 ], "max": [ 25, 25 ], "min": [ -25, -25 ], "step": 1, "scale": 1.0, "format": "%2.f", "screen": "raster" }
],
"parameters": [
{ "name": "alternating", "type": "frame", "period": 2 }
],
"targets": [
{ "name": "native",
"mode": "native",
"prescale": 1,
"doublebuffer": true
},
{ "name": "previous",
"mode": "native",
"prescale": 1,
"doublebuffer": true
}
],
"passes": [
{ "effect": "ratios",
"name": "Matrix Pass",
"disablewhen": [
{ "type": "slider", "condition": "equal", "name": "adjustments", "value": 0 },
{ "type": "slider", "condition": "equal", "name": "ratio_amount", "value": 0 }
],
"uniforms": [
{ "uniform": "u_ratio_amount", "slider": "ratio_amount" },
{ "uniform": "u_red_ratios", "slider": "red_ratios" },
{ "uniform": "u_grn_ratios", "slider": "grn_ratios" },
{ "uniform": "u_blu_ratios", "slider": "blu_ratios" }
],
"input": [
{ "sampler": "s_tex", "texture": "screen" }
],
"output": "native"
},
{ "effect": "blit",
"name": "Matrix Skip",
"disablewhen": [
{ "type": "slider", "condition": "equal", "name": "adjustments", "value": 0 },
{ "type": "slider", "condition": "notequal", "name": "ratio_amount", "value": 0 }
],
"input": [
{ "sampler": "s_tex", "texture": "screen" }
],
"output": "native"
},
{ "effect": "tint",
"name": "Tint Pass",
"disablewhen": [
{ "type": "slider", "condition": "equal", "name": "adjustments", "value": 0 }
],
"uniforms": [
{ "uniform": "u_tint", "slider": "tint" },
{ "uniform": "u_shift", "slider": "shift" }
],
"input": [
{ "sampler": "s_tex", "texture": "native" }
],
"output": "native"
},
{ "effect": "phosphor",
"name": "Phosphor Decay",
"disablewhen": [
{ "type": "slider", "condition": "equal", "name": "adjustments", "value": 0 },
{ "type": "slider", "condition": "equal", "name": "phosphor", "value": [ 0, 0, 0 ] }
],
"uniforms": [
{ "uniform": "u_passthrough", "value": [ 0 ] },
{ "uniform": "u_phosphor", "slider": "phosphor" }
],
"input": [
{ "sampler": "s_tex", "texture": "native" },
{ "sampler": "s_prev", "texture": "previous" }
],
"output": "native"
},
{ "effect": "phosphor",
"name": "Phosphor Store",
"disablewhen": [
{ "type": "slider", "condition": "equal", "name": "adjustments", "value": 0 },
{ "type": "slider", "condition": "equal", "name": "phosphor", "value": [ 0, 0, 0 ] }
],
"uniforms": [
{ "uniform": "u_passthrough", "value": [ 1 ] },
{ "uniform": "u_phosphor", "slider": "phosphor" }
],
"input": [
{ "sampler": "s_tex", "texture": "native" },
{ "sampler": "s_prev", "texture": "native" }
],
"output": "previous"
},
{ "effect": "blit",
"name": "Total Skip",
"disablewhen": [
{ "type": "slider", "condition": "notequal", "name": "adjustments", "value": 0 }
],
"input": [
{ "sampler": "s_tex", "texture": "screen" }
],
"output": "native"
}
],
"output": "native"
}

27
bgfx/effects/LICENSE Normal file
View File

@ -0,0 +1,27 @@
Copyright (c) 2016, Ryan Holtz and MAME Development Team
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of bsd3 nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

5
bgfx/effects/README.md Normal file
View File

@ -0,0 +1,5 @@
# **Tests** #
Cointains definitions for BGFX shader chains
Licensed under [The BSD 3-Clause License](http://opensource.org/licenses/BSD-3-Clause) by Ryan Holtz and MAME Development Team

View File

@ -1,23 +0,0 @@
{
"blend": {
"equation": "add",
"srcColor": "1",
"dstColor": "0",
"srcAlpha": "1",
"dstAlpha": "0"
},
"depth": {
"function": "always"
},
"cull": { "mode": "none" },
"write": {
"rgb": "true",
"alpha": "true"
},
"vertex": "vs_bloom_scale",
"fragment": "fs_bloom_scale",
"uniforms": [
{ "name": "DiffuseSampler", "type": "int", "values": [ 1.0 ] },
{ "name": "u_source_dims", "type": "vec4", "values": [ 1.0, 1.0, 0.0, 0.0 ] }
]
}

View File

@ -17,12 +17,12 @@
"vertex": "vs_color",
"fragment": "fs_color",
"uniforms": [
{ "name": "DiffuseSampler", "type": "int", "values": [ 1.0 ] },
{ "name": "s_tex", "type": "int", "values": [ 1.0 ] },
{ "name": "u_red_ratios", "type": "vec4", "values": [ 1.0, 0.0, 0.0, 0.0 ] },
{ "name": "u_grn_ratios", "type": "vec4", "values": [ 0.0, 1.0, 0.0, 0.0 ] },
{ "name": "u_blu_ratios", "type": "vec4", "values": [ 0.0, 0.0, 1.0, 0.0 ] },
{ "name": "u_offset", "type": "vec4", "values": [ 0.0, 0.0, 0.0, 0.0 ] },
{ "name": "u_scale", "type": "vec4", "values": [ 1.0, 1.0, 1.0, 0.0 ] },
{ "name": "u_saturation", "type": "vec4", "values": [ 1.0, 0.0, 0.0, 0.0 ] }
{ "name": "u_scale", "type": "vec4", "values": [ 0.95, 0.95, 0.95, 0.0 ] },
{ "name": "u_saturation", "type": "vec4", "values": [ 1.5, 0.0, 0.0, 0.0 ] }
]
}

View File

@ -17,17 +17,13 @@
"vertex": "vs_deconverge",
"fragment": "fs_deconverge",
"uniforms": [
{ "name": "DiffuseSampler", "type": "int", "values": [ 1.0 ] },
{ "name": "u_texsize", "type": "vec4", "values": [ 0.5, 0.0, 0.0, 0.0 ] },
{ "name": "u_screenrect", "type": "vec4", "values": [ 0.5, 0.0, 0.0, 0.0 ] },
{ "name": "u_converge_red", "type": "vec4", "values": [ 0.0, 0.0, 0.0, 0.0 ] },
{ "name": "u_converge_green", "type": "vec4", "values": [ 0.0, 0.0, 0.0, 0.0 ] },
{ "name": "s_tex", "type": "int", "values": [ 1.0 ] },
{ "name": "u_converge_red", "type": "vec4", "values": [ 0.5, 0.0, 0.0, 0.0 ] },
{ "name": "u_converge_green", "type": "vec4", "values": [ 0.0, 0.5, 0.0, 0.0 ] },
{ "name": "u_converge_blue", "type": "vec4", "values": [ 0.0, 0.0, 0.0, 0.0 ] },
{ "name": "u_radial_converge_red", "type": "vec4", "values": [ 0.0, 0.0, 0.0, 0.0 ] },
{ "name": "u_radial_converge_green", "type": "vec4", "values": [ 0.0, 0.0, 0.0, 0.0 ] },
{ "name": "u_radial_converge_blue", "type": "vec4", "values": [ 0.0, 0.0, 0.0, 0.0 ] },
{ "name": "u_swap_xy", "type": "vec4", "values": [ 0.0, 0.0, 0.0, 0.0 ] },
{ "name": "u_quad_dims", "type": "vec4", "values": [ 0.0, 0.0, 0.0, 0.0 ] },
{ "name": "u_guest_dims", "type": "vec4", "values": [ 0.0, 0.0, 0.0, 0.0 ] }
{ "name": "u_source_dims", "type": "vec4", "values": [ 256.0, 256.0, 0.0, 0.0 ] }
]
}

View File

@ -17,10 +17,8 @@
"vertex": "vs_defocus",
"fragment": "fs_defocus",
"uniforms": [
{ "name": "DiffuseSampler", "type": "int", "values": [ 1.0 ] },
{ "name": "s_tex", "type": "int", "values": [ 1.0 ] },
{ "name": "u_screen_dims", "type": "vec4", "values": [ 1.0, 0.0, 0.0, 0.0 ] },
{ "name": "u_swap_xy", "type": "vec4", "values": [ 0.0, 0.0, 0.0, 0.0 ] },
{ "name": "u_quad_dims", "type": "vec4", "values": [ 0.0, 0.0, 0.0, 0.0 ] },
{ "name": "u_defocus", "type": "vec4", "values": [ 0.0, 0.0, 0.0, 0.0 ] }
{ "name": "u_defocus", "type": "vec4", "values": [ 0.5, 0.5, 0.0, 0.0 ] }
]
}

View File

@ -17,13 +17,13 @@
"vertex": "vs_distortion",
"fragment": "fs_distortion",
"uniforms": [
{ "name": "DiffuseSampler", "type": "int", "values": [ 0.0 ] },
{ "name": "u_screen_dims", "type": "vec4", "values": [ 0.0, 0.0, 0.0, 0.0 ] },
{ "name": "u_curvature", "type": "vec4", "values": [ 0.0, 0.0, 0.0, 0.0 ] },
{ "name": "u_round_corner", "type": "vec4", "values": [ 0.0, 0.0, 0.0, 0.0 ] },
{ "name": "u_smooth_border", "type": "vec4", "values": [ 0.0, 0.0, 0.0, 0.0 ] },
{ "name": "u_vignetting", "type": "vec4", "values": [ 0.0, 0.0, 0.0, 0.0 ] },
{ "name": "u_reflection", "type": "vec4", "values": [ 0.0, 0.0, 0.0, 0.0 ] },
{ "name": "s_tex", "type": "int", "values": [ 0.0 ] },
{ "name": "u_screen_dims", "type": "vec4", "values": [ 1.0, 1.0, 0.0, 0.0 ] },
{ "name": "u_curvature", "type": "vec4", "values": [ 0.25, 0.0, 0.0, 0.0 ] },
{ "name": "u_round_corner", "type": "vec4", "values": [ 0.2, 0.0, 0.0, 0.0 ] },
{ "name": "u_smooth_border", "type": "vec4", "values": [ 0.05, 0.0, 0.0, 0.0 ] },
{ "name": "u_vignetting", "type": "vec4", "values": [ 0.20, 0.0, 0.0, 0.0 ] },
{ "name": "u_reflection", "type": "vec4", "values": [ 0.30, 0.0, 0.0, 0.0 ] },
{ "name": "u_rotation_type", "type": "vec4", "values": [ 0.0, 0.0, 0.0, 0.0 ] }
]
}

View File

@ -17,7 +17,7 @@
"vertex": "vs_ntsc_decode",
"fragment": "fs_ntsc_decode",
"uniforms": [
{ "name": "DiffuseSampler", "type": "int", "values": [ 1.0 ] },
{ "name": "s_tex", "type": "int", "values": [ 1.0 ] },
{ "name": "u_source_dims", "type": "vec4", "values": [ 1.0, 1.0, 0.0, 0.0 ] },
{ "name": "u_a_value", "type": "vec4", "values": [ 0.5, 0.5, 0.5, 0.5 ] },
{ "name": "u_b_value", "type": "vec4", "values": [ 0.5, 0.5, 0.5, 0.5 ] },

View File

@ -17,7 +17,7 @@
"vertex": "vs_ntsc_encode",
"fragment": "fs_ntsc_encode",
"uniforms": [
{ "name": "DiffuseSampler", "type": "int", "values": [ 1.0 ] },
{ "name": "s_tex", "type": "int", "values": [ 1.0 ] },
{ "name": "u_source_dims", "type": "vec4", "values": [ 1.0, 1.0, 0.0, 0.0 ] },
{ "name": "u_a_value", "type": "vec4", "values": [ 0.5, 0.0, 0.0, 0.0 ] },
{ "name": "u_b_value", "type": "vec4", "values": [ 0.5, 0.0, 0.0, 0.0 ] },

View File

@ -17,12 +17,11 @@
"vertex": "vs_post",
"fragment": "fs_post",
"uniforms": [
{ "name": "DiffuseSampler", "type": "int", "values": [ 0.0 ] },
{ "name": "ShadowSampler", "type": "int", "values": [ 1.0 ] },
{ "name": "s_tex", "type": "int", "values": [ 0.0 ] },
{ "name": "s_shadow", "type": "int", "values": [ 1.0 ] },
{ "name": "u_swap_xy", "type": "vec4", "values": [ 0.0, 0.0, 0.0, 0.0 ] },
{ "name": "u_screen_dims", "type": "vec4", "values": [ 1.0, 1.0, 0.0, 0.0 ] },
{ "name": "u_source_dims", "type": "vec4", "values": [ 1.0, 1.0, 0.0, 0.0 ] },
{ "name": "u_shadow_dims", "type": "vec4", "values": [ 32.0, 32.0, 0.0, 0.0 ] },
{ "name": "u_screen_dims", "type": "vec4", "values": [ 1336.0, 1002.0, 0.0, 0.0 ] },
{ "name": "u_source_dims", "type": "vec4", "values": [ 256.0, 256.0, 0.0, 0.0 ] },
{ "name": "u_shadow_uv_offset", "type": "vec4", "values": [ 0.0, 0.0, 0.0, 0.0 ] },
{ "name": "u_prepare_bloom", "type": "vec4", "values": [ 0.0, 0.0, 0.0, 0.0 ] },
{ "name": "u_prepare_vector", "type": "vec4", "values": [ 0.0, 0.0, 0.0, 0.0 ] },
@ -41,8 +40,7 @@
{ "name": "u_back_color", "type": "vec4", "values": [ 0.0, 0.0, 0.0, 0.0 ] },
{ "name": "u_shadow_tile_mode", "type": "vec4", "values": [ 0.0, 0.0, 0.0, 0.0 ] },
{ "name": "u_shadow_alpha", "type": "vec4", "values": [ 0.0, 0.0, 0.0, 0.0 ] },
{ "name": "u_shadow_count", "type": "vec4", "values": [ 6.0, 4.0, 0.0, 0.0 ] },
{ "name": "u_shadow_uv", "type": "vec4", "values": [ 0.25, 0.25, 0.0, 0.0 ] },
{ "name": "u_shadow_uv", "type": "vec4", "values": [ 0.25, 0.333, 0.0, 0.0 ] },
{ "name": "u_power", "type": "vec4", "values": [ 1.0, 1.0, 1.0, 0.0 ] },
{ "name": "u_floor", "type": "vec4", "values": [ 0.0, 0.0, 0.0, 0.0 ] }
]

View File

@ -1,26 +0,0 @@
{
"blend": {
"equation": "add",
"srcColor": "1",
"dstColor": "0",
"srcAlpha": "1",
"dstAlpha": "0"
},
"depth": {
"function": "always"
},
"cull": { "mode": "none" },
"write": {
"rgb": "true",
"alpha": "true"
},
"vertex": "vs_ratios",
"fragment": "fs_ratios",
"uniforms": [
{ "name": "s_tex", "type": "int", "values": [ 1.0 ] },
{ "name": "u_red_ratios", "type": "vec4", "values": [ 1.0, 0.0, 0.0, 1.0 ] },
{ "name": "u_grn_ratios", "type": "vec4", "values": [ 0.0, 1.0, 0.0, 1.0 ] },
{ "name": "u_blu_ratios", "type": "vec4", "values": [ 0.0, 0.0, 1.0, 1.0 ] },
{ "name": "u_ratio_amount", "type": "vec4", "values": [ 1.0, 0.0, 0.0, 0.0 ] }
]
}

View File

@ -1,25 +0,0 @@
{
"blend": {
"equation": "add",
"srcColor": "1",
"dstColor": "0",
"srcAlpha": "1",
"dstAlpha": "0"
},
"depth": {
"function": "always"
},
"cull": { "mode": "none" },
"write": {
"rgb": "true",
"alpha": "true"
},
"vertex": "vs_tint",
"fragment": "fs_tint",
"uniforms": [
{ "name": "s_tex", "type": "int", "values": [ 1.0 ] },
{ "name": "u_tint", "type": "vec4", "values": [ 1.0, 1.0, 1.0, 1.0 ] },
{ "name": "u_shift", "type": "vec4", "values": [ 0.1, 0.1, 0.0, 0.0 ] },
{ "name": "u_texsize", "type": "vec4", "values": [ 1.0, 1.0, 0.0, 0.0 ] }
]
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -144,6 +144,8 @@ const options_entry osd_options::s_option_entries[] =
{ OSDOPTION_BGFX_PATH, "bgfx", OPTION_STRING, "path to BGFX-related files" },
{ OSDOPTION_BGFX_SCREEN_CHAIN, "hlsl", OPTION_STRING, "screen chain JSON file to use" },
{ OSDOPTION_BGFX_SHADOW_MASK, "shadow-mask.png", OPTION_STRING, "shadow mask texture name" },
{ OSDOPTION_BGFX_PRESCALE_X, "1", OPTION_INTEGER, "x prescale" },
{ OSDOPTION_BGFX_PRESCALE_Y, "1", OPTION_INTEGER, "y prescale" },
// End of list
{ nullptr }

View File

@ -78,8 +78,10 @@
#define OSDOPTVAL_NONE "none"
#define OSDOPTION_BGFX_PATH "bgfx_path"
#define OSDOPTION_BGFX_SCREEN_CHAIN "screen_chain"
#define OSDOPTION_BGFX_SCREEN_CHAIN "bgfx_screen_chain"
#define OSDOPTION_BGFX_SHADOW_MASK "bgfx_shadow_mask"
#define OSDOPTION_BGFX_PRESCALE_X "bgfx_prescale_x"
#define OSDOPTION_BGFX_PRESCALE_Y "bgfx_prescale_y"
//============================================================
// TYPE DEFINITIONS
@ -153,6 +155,8 @@ public:
const char *bgfx_path() const { return value(OSDOPTION_BGFX_PATH); }
const char *bgfx_screen_chain() const { return value(OSDOPTION_BGFX_SCREEN_CHAIN); }
const char *bgfx_shadow_mask() const { return value(OSDOPTION_BGFX_SHADOW_MASK); }
const uint32_t bgfx_prescale_x() const { return int_value(OSDOPTION_BGFX_PRESCALE_X); }
const uint32_t bgfx_prescale_y() const { return int_value(OSDOPTION_BGFX_PRESCALE_Y); }
private:
static const options_entry s_option_entries[];

View File

@ -15,6 +15,7 @@
#include "entryuniform.h"
#include "texturemanager.h"
#include "vertex.h"
#include "window.h"
#include "chain.h"
@ -49,14 +50,24 @@ bgfx_chain::~bgfx_chain()
}
}
void bgfx_chain::process(render_primitive* prim, int view, texture_manager& textures, uint16_t screen_width, uint16_t screen_height, uint64_t blend)
void bgfx_chain::process(render_primitive* prim, int view, texture_manager& textures, osd_window& window, uint64_t blend)
{
int current_view = view;
uint16_t screen_width = window.get_size().width();
uint16_t screen_height = window.get_size().height();
uint32_t rotation_type = (window.target()->orientation() & ROT90) == ROT90 ?
1 : (window.target()->orientation() & ROT180) == ROT180 ?
2 : (window.target()->orientation() & ROT270) == ROT270 ?
3 : 0;
bool orientation_swap_xy = (window.machine().system().flags & ORIENTATION_SWAP_XY) == ORIENTATION_SWAP_XY;
bool rotation_swap_xy = (window.target()->orientation() & ROT90) == ROT90 || (window.target()->orientation() & ROT270) == ROT270;
bool swap_xy = orientation_swap_xy ^ rotation_swap_xy;
for (bgfx_chain_entry* entry : m_entries)
{
if (!entry->skip())
{
entry->submit(prim, current_view, textures, screen_width, screen_height, blend);
entry->submit(current_view, prim, textures, screen_width, screen_height, rotation_type, swap_xy, blend);
current_view++;
}
}

View File

@ -21,6 +21,7 @@ class render_primitive;
class bgfx_slider;
class bgfx_parameter;
class texture_manager;
class osd_window;
class bgfx_chain
{
@ -28,7 +29,7 @@ public:
bgfx_chain(std::string name, std::string author, std::vector<bgfx_slider*> sliders, std::vector<bgfx_parameter*> params, std::vector<bgfx_chain_entry*> entries, std::string output);
~bgfx_chain();
void process(render_primitive* prim, int view, texture_manager& textures, uint16_t screen_width, uint16_t screen_height, uint64_t blend = 0L);
void process(render_primitive* prim, int view, texture_manager& textures, osd_window &window, uint64_t blend = 0L);
// Getters
std::vector<bgfx_slider*>& sliders() { return m_sliders; }

View File

@ -44,7 +44,7 @@ bgfx_chain_entry::~bgfx_chain_entry()
m_uniforms.clear();
}
void bgfx_chain_entry::submit(render_primitive* prim, int view, texture_manager& textures, uint16_t screen_width, uint16_t screen_height, uint64_t blend)
void bgfx_chain_entry::submit(int view, render_primitive* prim, texture_manager& textures, uint16_t screen_width, uint16_t screen_height, uint32_t rotation_type, bool swap_xy, uint64_t blend)
{
bgfx::setViewSeq(view, true);
@ -59,56 +59,11 @@ void bgfx_chain_entry::submit(render_primitive* prim, int view, texture_manager&
put_screen_buffer(prim, &buffer);
bgfx::setVertexBuffer(&buffer);
bgfx_uniform* inv_screen_dims = m_effect->uniform("u_inv_screen_dims");
bgfx_uniform* screen_dims = m_effect->uniform("u_screen_dims");
if (screen_dims != nullptr || inv_screen_dims != nullptr)
{
float values[2];
float width = screen_width;
float height = screen_height;
if (m_inputs.size() > 0)
{
width = float(textures.provider(m_inputs[0].texture())->width());
height = float(textures.provider(m_inputs[0].texture())->height());
}
values[0] = 1.0f / width;
values[1] = 1.0f / height;
if (inv_screen_dims != nullptr) {
inv_screen_dims->set(values, sizeof(float) * 2);
}
values[0] = width;
values[1] = height;
if (screen_dims != nullptr) {
screen_dims->set(values, sizeof(float) * 2);
}
}
bgfx_uniform* quad_dims = m_effect->uniform("u_quad_dims");
if (quad_dims != nullptr)
{
float values[2];
values[0] = prim->bounds.x1 - prim->bounds.x0;
values[1] = prim->bounds.y1 - prim->bounds.y0;
quad_dims->set(values, sizeof(float) * 2);
}
bgfx_uniform* source_dims = m_effect->uniform("u_source_dims");
if (source_dims != nullptr)
{
float values[2];
values[0] = float(prim->texture.width);
values[1] = float(prim->texture.height);
if (source_dims != nullptr)
{
source_dims->set(values, sizeof(float) * 2);
}
}
setup_auto_uniforms(prim, textures, screen_width, screen_height, rotation_type, swap_xy);
for (bgfx_entry_uniform* uniform : m_uniforms)
{
if (uniform->name() != "DiffuseSampler")
if (uniform->name() != "s_tex")
{
uniform->bind();
}
@ -122,6 +77,69 @@ void bgfx_chain_entry::submit(render_primitive* prim, int view, texture_manager&
}
}
void bgfx_chain_entry::setup_screensize_uniforms(texture_manager& textures, uint16_t screen_width, uint16_t screen_height)
{
float width = screen_width;
float height = screen_height;
if (m_inputs.size() > 0)
{
width = float(textures.provider(m_inputs[0].texture())->width());
height = float(textures.provider(m_inputs[0].texture())->height());
}
bgfx_uniform* screen_dims = m_effect->uniform("u_screen_dims");
if (screen_dims != nullptr)
{
float values[2] = { width, height };
screen_dims->set(values, sizeof(float) * 2);
}
bgfx_uniform* inv_screen_dims = m_effect->uniform("u_inv_screen_dims");
if (inv_screen_dims != nullptr)
{
float values[2] = { 1.0f / width, 1.0f / height };
inv_screen_dims->set(values, sizeof(float) * 2);
}
}
void bgfx_chain_entry::setup_sourcesize_uniform(render_primitive* prim)
{
bgfx_uniform* source_dims = m_effect->uniform("u_source_dims");
if (source_dims != nullptr)
{
float values[2] = { float(prim->texture.width), float(prim->texture.height) };
source_dims->set(values, sizeof(float) * 2);
}
}
void bgfx_chain_entry::setup_rotationtype_uniform(uint32_t rotation_type)
{
bgfx_uniform* rotation_type_uniform = m_effect->uniform("u_rotation_type");
if (rotation_type_uniform != nullptr)
{
float values[1] = { float(rotation_type) };
rotation_type_uniform->set(values, sizeof(float));
}
}
void bgfx_chain_entry::setup_swapxy_uniform(bool swap_xy)
{
bgfx_uniform* swap_xy_uniform = m_effect->uniform("u_swap_xy");
if (swap_xy_uniform != nullptr)
{
float values[1] = { swap_xy ? 1.0f : 0.0f };
swap_xy_uniform->set(values, sizeof(float));
}
}
void bgfx_chain_entry::setup_auto_uniforms(render_primitive* prim, texture_manager& textures, uint16_t screen_width, uint16_t screen_height, uint32_t rotation_type, bool swap_xy)
{
setup_screensize_uniforms(textures, screen_width, screen_height);
setup_sourcesize_uniform(prim);
setup_rotationtype_uniform(rotation_type);
setup_swapxy_uniform(swap_xy);
}
void bgfx_chain_entry::setup_view(int view, uint16_t screen_width, uint16_t screen_height)
{
bgfx::FrameBufferHandle handle = BGFX_INVALID_HANDLE;
@ -131,8 +149,8 @@ void bgfx_chain_entry::setup_view(int view, uint16_t screen_width, uint16_t scre
{
bgfx_target* output = m_targets.target(m_output);
handle = output->target();
width = output->width();
height = output->height();
width = output->width() * output->prescale_x();
height = output->height() * output->prescale_y();
}
bgfx::setViewFrameBuffer(view, handle);

View File

@ -36,7 +36,7 @@ public:
bgfx_chain_entry(std::string name, bgfx_effect* effect, std::vector<bgfx_suppressor*> suppressors, std::vector<bgfx_input_pair> inputs, std::vector<bgfx_entry_uniform*> uniforms, target_manager& targets, std::string output);
~bgfx_chain_entry();
void submit(render_primitive* prim, int view, texture_manager& textures, uint16_t screen_width, uint16_t screen_height, uint64_t blend);
void submit(int view, render_primitive* prim, texture_manager& textures, uint16_t screen_width, uint16_t screen_height, uint32_t rotation_type, bool swap_xy, uint64_t blend);
// Getters
std::string name() const { return m_name; }
@ -44,6 +44,12 @@ public:
bool skip();
private:
void setup_auto_uniforms(render_primitive* prim, texture_manager& textures, uint16_t screen_width, uint16_t screen_height, uint32_t rotation_type, bool swap_xy);
void setup_screensize_uniforms(texture_manager& textures, uint16_t screen_width, uint16_t screen_height);
void setup_sourcesize_uniform(render_primitive* prim);
void setup_rotationtype_uniform(uint32_t rotation_type);
void setup_swapxy_uniform(bool swap_xy);
void setup_view(int view, uint16_t screen_width, uint16_t screen_height);
void put_screen_buffer(render_primitive* prim, bgfx::TransientVertexBuffer* buffer);

View File

@ -10,6 +10,7 @@
#include "emu.h"
#include "rendutil.h"
#include <modules/render/copyutil.h>
#include <modules/lib/osdobj_common.h>
@ -73,11 +74,10 @@ bgfx_chain_entry* chain_entry_reader::read_from_value(const Value& value, osd_op
const Value& texture_array = value["textures"];
for (UINT32 i = 0; i < texture_array.Size(); i++)
{
char texture_name[2048];
bitmap_argb32 bitmap;
emu_file file(options.bgfx_shadow_mask(), OPEN_FLAG_READ);
strcpy(texture_name, options.bgfx_shadow_mask());
render_load_png(bitmap, file, nullptr, texture_name);
std::string texture_path = std::string(options.bgfx_path()) + "/artwork/";
std::string texture_name = texture_array[i].GetString();
textures.create_png_texture(texture_path, texture_name, texture_name);
}
}

View File

@ -11,6 +11,7 @@
#include <map>
#include "emu.h"
#include <modules/lib/osdobj_common.h>
#include "chain.h"
#include "sliderreader.h"
@ -87,11 +88,7 @@ bgfx_chain* chain_reader::read_from_value(const Value& value, osd_options& optio
uint32_t mode = uint32_t(get_enum_from_value(target_array[i], "mode", TARGET_STYLE_NATIVE, STYLE_NAMES, STYLE_COUNT));
bool bilinear = get_bool(target_array[i], "bilinear", true);
bool double_buffer = get_bool(target_array[i], "doublebuffer", true);
float prescalef = 1.0f;
float default_prescale = 1.0f;
get_float(target_array[i], "prescale", &prescalef, &default_prescale);
int prescale = (int)floor(prescalef + 0.5f);
bool prescale = get_bool(target_array[i], "prescale", false);
uint16_t width = 0;
uint16_t height = 0;
@ -115,10 +112,14 @@ bgfx_chain* chain_reader::read_from_value(const Value& value, osd_options& optio
break;
}
width *= prescale;
height *= prescale;
targets.create_target(target_array[i]["name"].GetString(), bgfx::TextureFormat::RGBA8, width, height, mode, double_buffer, bilinear);
uint32_t prescale_x = 1;
uint32_t prescale_y = 1;
if (prescale)
{
prescale_x = options.bgfx_prescale_x();
prescale_y = options.bgfx_prescale_y();
}
targets.create_target(target_array[i]["name"].GetString(), bgfx::TextureFormat::RGBA8, width, height, prescale_x, prescale_y, mode, double_buffer, bilinear);
}
}

View File

@ -5,6 +5,7 @@ $input v_color0, v_texcoord0
#include "../../../../../3rdparty/bgfx/examples/common/common.sh"
// Samplers
SAMPLER2D(s_tex, 0);
void main()

View File

@ -6,10 +6,9 @@ $input v_color0, v_texcoord0
// Color Convolution Effect
//-----------------------------------------------------------------------------
// NB: intentionally wasteful of uniforms in order for easier slider utilization
#include "../../../../../3rdparty/bgfx/examples/common/common.sh"
// User-supplied
uniform vec4 u_red_ratios;
uniform vec4 u_grn_ratios;
uniform vec4 u_blu_ratios;
@ -17,34 +16,28 @@ uniform vec4 u_offset;
uniform vec4 u_scale;
uniform vec4 u_saturation;
#define RedRatios u_red_ratios.xyz
#define GrnRatios u_grn_ratios.xyz
#define BluRatios u_blu_ratios.xyz
#define Offset u_offset.xyz
#define Scale u_scale.xyz
#define Saturation u_saturation.x
SAMPLER2D(DiffuseSampler, 0);
// Samplers
SAMPLER2D(s_tex, 0);
void main()
{
vec4 BaseTexel = texture2D(DiffuseSampler, v_texcoord0);
vec4 BaseTexel = texture2D(s_tex, v_texcoord0);
vec3 OutRGB = BaseTexel.rgb;
// RGB Tint & Shift
float ShiftedRed = dot(OutRGB, RedRatios);
float ShiftedGrn = dot(OutRGB, GrnRatios);
float ShiftedBlu = dot(OutRGB, BluRatios);
float ShiftedRed = dot(OutRGB, u_red_ratios.xyz);
float ShiftedGrn = dot(OutRGB, u_grn_ratios.xyz);
float ShiftedBlu = dot(OutRGB, u_blu_ratios.xyz);
// RGB Scale & Offset
vec3 OutTexel = vec3(ShiftedRed, ShiftedGrn, ShiftedBlu) * Scale + Offset;
vec3 OutTexel = vec3(ShiftedRed, ShiftedGrn, ShiftedBlu) * u_scale.xyz + u_offset.xyz;
// Saturation
vec3 Grayscale = vec3(0.299, 0.587, 0.114);
float OutLuma = dot(OutTexel, Grayscale);
vec3 OutChroma = OutTexel - OutLuma;
vec3 Saturated = OutLuma + OutChroma * Saturation;
vec3 Saturated = OutLuma + OutChroma * u_saturation.x;
gl_FragColor = vec4(Saturated, BaseTexel.a);
}

View File

@ -6,16 +6,15 @@ $input v_color0, v_texcoord0, v_texcoord1, v_texcoord2
// Deconvergence Effect
//-----------------------------------------------------------------------------
// NB: intentionally wasteful of uniforms in order for easier slider utilization
#include "../../../../../3rdparty/bgfx/examples/common/common.sh"
SAMPLER2D(DiffuseSampler, 0);
// Samplers
SAMPLER2D(s_tex, 0);
void main()
{
float r = texture2D(DiffuseSampler, v_texcoord0).r;
float g = texture2D(DiffuseSampler, v_texcoord1).g;
float b = texture2D(DiffuseSampler, v_texcoord2).b;
float r = texture2D(s_tex, v_texcoord0).r;
float g = texture2D(s_tex, v_texcoord1).g;
float b = texture2D(s_tex, v_texcoord2).b;
gl_FragColor = vec4(r, g, b, 1.0) * v_color0;
}

View File

@ -8,14 +8,14 @@ $input v_color0, v_texcoord0
#include "../../../../../3rdparty/bgfx/examples/common/common.sh"
uniform vec4 u_screenrect;
uniform vec4 u_defocus;
uniform vec4 u_swap_xy;
// Autos
uniform vec4 u_screen_dims;
SAMPLER2D(DiffuseSampler, 0);
// User-supplied
uniform vec4 u_defocus;
// Samplers
SAMPLER2D(s_tex, 0);
//-----------------------------------------------------------------------------
// Constants
@ -32,19 +32,17 @@ void main()
const vec2 Coord7Offset = vec2( 0.50, -0.75);
const vec2 Coord8Offset = vec2( 1.00, -0.25);
vec2 QuadRatio = vec2(1.0, (u_swap_xy.x > 0.0) ? u_screen_dims.y / u_screen_dims.x : u_screen_dims.x / u_screen_dims.y);
vec2 DefocusTexelDims = u_defocus.xy / u_screen_dims.xy;
vec4 d0 = texture2D(DiffuseSampler, v_texcoord0);
vec4 d1 = texture2D(DiffuseSampler, v_texcoord0 + Coord1Offset * DefocusTexelDims);
vec4 d2 = texture2D(DiffuseSampler, v_texcoord0 + Coord2Offset * DefocusTexelDims);
vec4 d3 = texture2D(DiffuseSampler, v_texcoord0 + Coord3Offset * DefocusTexelDims);
vec4 d4 = texture2D(DiffuseSampler, v_texcoord0 + Coord4Offset * DefocusTexelDims);
vec4 d5 = texture2D(DiffuseSampler, v_texcoord0 + Coord5Offset * DefocusTexelDims);
vec4 d6 = texture2D(DiffuseSampler, v_texcoord0 + Coord6Offset * DefocusTexelDims);
vec4 d7 = texture2D(DiffuseSampler, v_texcoord0 + Coord7Offset * DefocusTexelDims);
vec4 d8 = texture2D(DiffuseSampler, v_texcoord0 + Coord8Offset * DefocusTexelDims);
vec4 d0 = texture2D(s_tex, v_texcoord0);
vec4 d1 = texture2D(s_tex, v_texcoord0 + Coord1Offset * DefocusTexelDims);
vec4 d2 = texture2D(s_tex, v_texcoord0 + Coord2Offset * DefocusTexelDims);
vec4 d3 = texture2D(s_tex, v_texcoord0 + Coord3Offset * DefocusTexelDims);
vec4 d4 = texture2D(s_tex, v_texcoord0 + Coord4Offset * DefocusTexelDims);
vec4 d5 = texture2D(s_tex, v_texcoord0 + Coord5Offset * DefocusTexelDims);
vec4 d6 = texture2D(s_tex, v_texcoord0 + Coord6Offset * DefocusTexelDims);
vec4 d7 = texture2D(s_tex, v_texcoord0 + Coord7Offset * DefocusTexelDims);
vec4 d8 = texture2D(s_tex, v_texcoord0 + Coord8Offset * DefocusTexelDims);
vec4 blurred = (d0 + d1 + d2 + d3 + d4 + d5 + d6 + d7 + d8) / 9.0;

View File

@ -3,44 +3,26 @@ $input v_color0, v_texcoord0
// license:BSD-3-Clause
// copyright-holders:Ryan Holtz,ImJezze
//-----------------------------------------------------------------------------
// Defocus Effect
// Distortion Effect
//-----------------------------------------------------------------------------
#include "../../../../../3rdparty/bgfx/examples/common/common.sh"
//-----------------------------------------------------------------------------
// Constants
//-----------------------------------------------------------------------------
SAMPLER2D(DiffuseSampler, 0);
//-----------------------------------------------------------------------------
// Uniforms
//-----------------------------------------------------------------------------
// Autos
uniform vec4 u_screen_dims;
uniform vec4 u_rotation_type;
// User-supplied
uniform vec4 u_curvature;
uniform vec4 u_round_corner;
uniform vec4 u_smooth_border;
uniform vec4 u_vignetting;
uniform vec4 u_reflection;
uniform vec4 u_rotation_type; // TODO
// Samplers
SAMPLER2D(s_tex, 0);
#define CurvatureAmount u_curvature.x
#define RoundCornerAmount u_round_corner.x
#define SmoothBorderAmount u_smooth_border.x
#define VignettingAmount u_vignetting.x
#define ReflectionAmount u_reflection.x
#define RotationType u_rotation_type.x // TODO
//-----------------------------------------------------------------------------
// Functions
//-----------------------------------------------------------------------------
// Holy fuck the number of functions...
// www.stackoverflow.com/questions/5149544/can-i-generate-a-random-number-inside-a-pixel-shader/
float rand(vec2 seed)
@ -103,11 +85,11 @@ float GetSpotAddend(vec2 coord, float amount)
// normalized screen quad ratio
// upper right quadrant
vec2 spotOffset = vec2(-0.25, 0.25); // 0 degrees
if (RotationType == 1.0)
if (u_rotation_type.x == 1.0)
spotOffset = vec2(-0.25, -0.25); // 90 degrees
if (RotationType == 2.0)
if (u_rotation_type.x == 2.0)
spotOffset = vec2(0.25, -0.25); // 180 degrees
if (RotationType == 3.0)
if (u_rotation_type.x == 3.0)
spotOffset = vec2(0.25, 0.25); // 270 degrees
vec2 SpotCoord = (coord + spotOffset * RatioCorrection) / RatioCorrection;
@ -193,20 +175,18 @@ vec2 GetCoords(vec2 coord, float distortionAmount)
return coord;
}
//-----------------------------------------------------------------------------
// Distortion Pixel Shader
//-----------------------------------------------------------------------------
// Shader
void main()
{
// Screen Curvature
vec2 BaseCoord = GetCoords(v_texcoord0, CurvatureAmount * 0.25); // reduced amount
vec2 BaseCoord = GetCoords(v_texcoord0, u_curvature.x * 0.25); // reduced amount
vec2 BaseCoordCentered = BaseCoord;
BaseCoordCentered -= 0.5;
// Color
vec4 BaseColor = texture2D(DiffuseSampler, BaseCoord);
vec4 BaseColor = texture2D(s_tex, BaseCoord);
BaseColor.a = 1.0;
// Clamp
@ -216,7 +196,7 @@ void main()
// Vignetting Simulation
vec2 VignetteCoord = BaseCoordCentered;
float VignetteFactor = GetVignetteFactor(VignetteCoord, VignettingAmount);
float VignetteFactor = GetVignetteFactor(VignetteCoord, u_vignetting.x);
BaseColor.rgb *= VignetteFactor;
// Light Reflection Simulation
@ -225,14 +205,14 @@ void main()
vec2 SpotCoord = BaseCoordCentered;
vec2 NoiseCoord = BaseCoordCentered;
float SpotAddend = GetSpotAddend(SpotCoord, ReflectionAmount);
float SpotAddend = GetSpotAddend(SpotCoord, u_reflection.x);
float NoiseFactor = GetNoiseFactor(SpotAddend, rand(NoiseCoord));
BaseColor.rgb += SpotAddend * NoiseFactor * LightColor;
// Round Corners Simulation
vec2 RoundCornerCoord = BaseCoordCentered;
float roundCornerFactor = GetRoundCornerFactor(RoundCornerCoord, RoundCornerAmount, SmoothBorderAmount);
float roundCornerFactor = GetRoundCornerFactor(RoundCornerCoord, u_round_corner.x, u_smooth_border.x);
BaseColor.rgb *= roundCornerFactor;
gl_FragColor = BaseColor;

View File

@ -5,10 +5,10 @@ $input v_color0, v_texcoord0
#include "../../../../../3rdparty/bgfx/examples/common/common.sh"
// Samplers
SAMPLER2D(s_tex, 0);
void main()
{
vec4 texel = texture2D(s_tex, v_texcoord0);
gl_FragColor = texel * v_color0;
gl_FragColor = texture2D(s_tex, v_texcoord0) * v_color0;
}

View File

@ -6,10 +6,12 @@ $input v_color0, v_texcoord0
// NTSC Decode Effect
//-----------------------------------------------------------------------------
// NB: intentionally wasteful of uniforms in order for easier slider utilization
#include "../../../../../3rdparty/bgfx/examples/common/common.sh"
// Autos
uniform vec4 u_source_dims;
// User-supplied
uniform vec4 u_a_value;
uniform vec4 u_b_value;
uniform vec4 u_cc_value;
@ -19,12 +21,13 @@ uniform vec4 u_notch_width;
uniform vec4 u_y_freq_response;
uniform vec4 u_i_freq_response;
uniform vec4 u_q_freq_response;
uniform vec4 u_jitter_amount;
uniform vec4 u_jitter_offset;
uniform vec4 u_source_dims;
// Parametric
uniform vec4 u_jitter_amount;
SAMPLER2D(DiffuseSampler, 0);
// Samplers
SAMPLER2D(s_tex, 0);
//-----------------------------------------------------------------------------
// Constants
@ -32,7 +35,7 @@ SAMPLER2D(DiffuseSampler, 0);
void main()
{
vec4 BaseTexel = texture2D(DiffuseSampler, v_texcoord0.xy);
vec4 BaseTexel = texture2D(s_tex, v_texcoord0.xy);
vec4 zero = vec4(0.0, 0.0, 0.0, 0.0);
vec4 quarter = vec4(0.25, 0.25, 0.25, 0.25);
@ -71,7 +74,7 @@ void main()
vec4 Cx = v_texcoord0.xxxx + u_source_dims.xxxx * (n4 * quarter);
// theory: What if we put white in the input of the NTSC decode shader?
vec4 C = texture2D(DiffuseSampler, vec2(Cx.x, v_texcoord0.y));
vec4 C = texture2D(s_tex, vec2(Cx.x, v_texcoord0.y));
vec4 T = Cx + HOffset + v_texcoord0.yyyy * VScale;
vec4 WT = W * T + u_o_value.xxxx;

View File

@ -10,17 +10,22 @@ $input v_color0, v_texcoord0
#include "../../../../../3rdparty/bgfx/examples/common/common.sh"
// Autos
uniform vec4 u_source_dims;
// User-supplied
uniform vec4 u_a_value;
uniform vec4 u_b_value;
uniform vec4 u_cc_value;
uniform vec4 u_p_value;
uniform vec4 u_scan_time;
uniform vec4 u_jitter_amount;
uniform vec4 u_jitter_offset;
uniform vec4 u_source_dims;
// Parametric
uniform vec4 u_jitter_amount;
SAMPLER2D(DiffuseSampler, 0);
// Samplers
SAMPLER2D(s_tex, 0);
//-----------------------------------------------------------------------------
// Constants
@ -36,10 +41,10 @@ void main()
vec2 C3 = v_texcoord0 + PValueSourceTexel * vec2(0.75, 0.0);
vec4 Cx = vec4(C0.x, C1.x, C2.x, C3.x);
vec4 Cy = vec4(C0.y, C1.y, C2.y, C3.y);
vec4 Texel0 = texture2D(DiffuseSampler, C0);
vec4 Texel1 = texture2D(DiffuseSampler, C1);
vec4 Texel2 = texture2D(DiffuseSampler, C2);
vec4 Texel3 = texture2D(DiffuseSampler, C3);
vec4 Texel0 = texture2D(s_tex, C0);
vec4 Texel1 = texture2D(s_tex, C1);
vec4 Texel2 = texture2D(s_tex, C2);
vec4 Texel3 = texture2D(s_tex, C3);
vec4 HPosition = Cx;
vec4 VPosition = Cy;

View File

@ -5,9 +5,11 @@ $input v_color0, v_texcoord0
#include "../../../../../3rdparty/bgfx/examples/common/common.sh"
// User-supplied
uniform vec4 u_passthrough;
uniform vec4 u_phosphor;
// Samplers
SAMPLER2D(s_tex, 0);
SAMPLER2D(s_prev, 1);

View File

@ -8,45 +8,39 @@ $input v_color0, v_texcoord0, v_texcoord1
#include "../../../../../3rdparty/bgfx/examples/common/common.sh"
// Autos
uniform vec4 u_swap_xy;
uniform vec4 u_screen_dims; // size of the output window
uniform vec4 u_source_dims; // size of the guest machine
uniform vec4 u_screen_scale; // TODO: Hook up ScreenScale code-side
uniform vec4 u_screen_offset; // TODO: Hook up ScreenOffset code-side
uniform vec4 u_inv_screen_dims; // size of the window or fullscreen
uniform vec4 u_source_dims; // size of the source texture
uniform vec4 u_shadow_dims; // size of the shadow texture (extended to power-of-two size - not necessarily in bgfx)
uniform vec4 u_shadow_uv_offset;
// User-supplied
uniform vec4 u_prepare_bloom; // disables some effects for rendering bloom textures
uniform vec4 u_prepare_vector;
uniform vec4 u_humbar_hertz_rate; // 60.0f / 59.94f - 1.0f; // difference between the 59.94 Hz field rate and 60 Hz line frequency (NTSC)
uniform vec4 u_humbar_alpha; // 0.0f;
uniform vec4 u_time; // 0.0f;
uniform vec4 u_screen_scale; // TODO: ScreenScale
uniform vec4 u_screen_offset; // TODO: ScreenOffset
uniform vec4 u_scanline_alpha;
uniform vec4 u_scanline_scale;
uniform vec4 u_scanline_bright_scale;
uniform vec4 u_scanline_bright_offset;
uniform vec4 u_scanline_jitter;
uniform vec4 u_jitter_amount;
uniform vec4 u_scanline_height;
uniform vec4 u_back_color; // TODO: Unused in current implementation, mostly
uniform vec4 u_shadow_tile_mode; // 0 based on screen dimension, 1 based on source dimension
uniform vec4 u_shadow_alpha;
uniform vec4 u_shadow_uv;
uniform vec4 u_shadow_uv_offset;
uniform vec4 u_humbar_hertz_rate; // difference between the 59.94 Hz field rate and 60 Hz line frequency (NTSC)
uniform vec4 u_humbar_alpha;
uniform vec4 u_power;
uniform vec4 u_floor;
uniform vec4 u_shadow_tile_mode; // ShadowTileMode = 0; // 0 based on screen dimension, 1 based on source dimension
uniform vec4 u_shadow_alpha; // ShadowAlpha = 0.0f;
uniform vec4 u_shadow_count; // ShadowCount = float2(6.0f, 6.0f);
uniform vec4 u_shadow_uv; // ShadowUV = float2(0.25f, 0.25f);
// Parametric
uniform vec4 u_time;
uniform vec4 u_jitter_amount;
uniform vec4 u_power; // Power = float3(1.0f, 1.0f, 1.0f);
uniform vec4 u_floor; // Floor = float3(0.0f, 0.0f, 0.0f);
SAMPLER2D(DiffuseSampler, 0);
SAMPLER2D(ShadowSampler, 1);
// Samplers
SAMPLER2D(s_tex, 0);
SAMPLER2D(s_shadow, 1);
//-----------------------------------------------------------------------------
// Scanline & Shadowmask Pixel Shader
@ -71,17 +65,17 @@ vec2 GetAdjustedCoords(vec2 coord, vec2 center_offset)
void main()
{
vec2 ScreenTexelDims = u_inv_screen_dims.xy;
vec2 ScreenTexelDims = vec2(1.0, 1.0) / u_screen_dims.xy;
vec2 SourceTexelDims = vec2(1.0, 1.0) / u_source_dims.xy;
vec2 SourceRes = u_source_dims.xy;
vec2 HalfSourceRect = vec2(0.5, 0.5);
vec2 ScreenCoord = v_texcoord1 / u_inv_screen_dims.xy;
vec2 ScreenCoord = v_texcoord0.xy;
vec2 BaseCoord = GetAdjustedCoords(v_texcoord0, HalfSourceRect);
// Color
vec4 BaseColor = texture2D(DiffuseSampler, BaseCoord);
vec4 BaseColor = texture2D(s_tex, BaseCoord);
BaseColor.a = 1.0;
if (BaseCoord.x < 0.0 || BaseCoord.y < 0.0)
@ -92,18 +86,16 @@ void main()
// Mask Simulation (may not affect bloom)
if (u_prepare_bloom.x == 0.0 && u_shadow_alpha.x > 0.0)
{
vec2 shadowDims = u_swap_xy.x > 0.0 ? u_shadow_dims.yx : u_shadow_dims.xy;
vec2 screenCoord = u_shadow_tile_mode.x == 0.0 ? ScreenCoord : BaseCoord;
vec2 screenCoord = ScreenCoord;
screenCoord = u_swap_xy.x > 0.0 ? screenCoord.yx : screenCoord.xy;
vec2 shadowCount = u_swap_xy.x > 0.0 ? u_shadow_count.yx : u_shadow_count.xy;
vec2 shadowTile = ((u_shadow_tile_mode.x == 0.0 ? ScreenTexelDims : SourceTexelDims) * shadowCount);
vec2 shadowTile = (u_shadow_tile_mode.x == 0.0 ? u_screen_dims.xy : u_source_dims.xy);
shadowTile = u_swap_xy.x > 0.0 ? shadowTile.yx : shadowTile.xy;
vec2 ShadowFrac = fract(screenCoord / shadowTile);
vec2 ShadowFrac = fract(screenCoord * shadowTile);
vec2 ShadowCoord = (ShadowFrac * u_shadow_uv.xy);
vec4 ShadowColor = texture2D(ShadowSampler, ShadowCoord);
vec4 ShadowColor = texture2D(s_shadow, ShadowCoord);
vec3 ShadowMaskColor = mix(vec3(1.0, 1.0, 1.0), ShadowColor.rgb, u_shadow_alpha.xxx);
float ShadowMaskClear = (1.0 - ShadowColor.a) * u_shadow_alpha.x;

View File

@ -1,23 +0,0 @@
$input v_color0, v_texcoord0
// license:BSD-3-Clause
// copyright-holders:Dario Manesku
#include "../../../../../3rdparty/bgfx/examples/common/common.sh"
uniform vec4 u_ratio_amount;
uniform vec4 u_red_ratios;
uniform vec4 u_grn_ratios;
uniform vec4 u_blu_ratios;
SAMPLER2D(s_tex, 0);
void main()
{
vec4 texel = texture2D(s_tex, v_texcoord0);
float red = dot(texel.rgb, u_red_ratios.rgb);
float grn = dot(texel.rgb, u_grn_ratios.rgb);
float blu = dot(texel.rgb, u_blu_ratios.rgb);
vec3 mixed = mix(texel.rgb, vec3(red, grn, blu), u_ratio_amount.x);
gl_FragColor = vec4(mixed, texel.a) * v_color0;
}

View File

@ -5,6 +5,7 @@ $input v_color0, v_texcoord0
#include "../../../../../3rdparty/bgfx/examples/common/common.sh"
// Samplers
SAMPLER2D(s_tex, 0);
void main()

View File

@ -1,17 +0,0 @@
$input v_color0, v_texcoord0
// license:BSD-3-Clause
// copyright-holders:Dario Manesku
#include "../../../../../3rdparty/bgfx/examples/common/common.sh"
uniform vec4 u_tint;
uniform vec4 u_shift;
SAMPLER2D(s_tex, 0);
uniform vec4 u_texsize;
void main()
{
gl_FragColor = texture2D(s_tex, v_texcoord0.xy + u_shift.xy * u_texsize.xy) * u_tint * v_color0 + vec4(0.0, 0.0, 0.0, 1.0);
}

View File

@ -9,6 +9,8 @@
//
//============================================================
#include "emu.h"
#include "inputpair.h"
#include "texture.h"
#include "target.h"
@ -25,5 +27,6 @@ bgfx_input_pair::bgfx_input_pair(int index, std::string sampler, std::string tex
void bgfx_input_pair::bind(bgfx_effect *effect, texture_manager& textures) const
{
assert(effect->uniform(m_sampler) != nullptr);
bgfx::setTexture(m_index, effect->uniform(m_sampler)->handle(), textures.handle(m_texture));
}

View File

@ -27,8 +27,7 @@ bgfx_slider::bgfx_slider(running_machine &machine, std::string name, int32_t min
m_value = def;
if (m_type != slider_type::SLIDER_INT && m_type != slider_type::SLIDER_INT_ENUM)
{
float temp = float(def) * scale;
m_value = *reinterpret_cast<int32_t*>(&temp);
m_value = float(def) * scale;
}
for (std::string string : strings)
@ -75,30 +74,28 @@ int32_t bgfx_slider::update(std::string *str, int32_t newval)
{
case SLIDER_INT_ENUM:
{
INT32 *val_ptr = reinterpret_cast<INT32 *>(&m_value);
if (newval != SLIDER_NOCHANGE)
{
*val_ptr = newval;
m_value = float(newval);
}
if (str != nullptr)
{
*str = string_format(m_format, m_strings[*val_ptr]);
*str = string_format(m_format, m_strings[as_int()]);
}
return *val_ptr;
return as_int();
}
case SLIDER_INT:
{
int *val_ptr = reinterpret_cast<int *>(&m_value);
if (newval != SLIDER_NOCHANGE)
{
*val_ptr = newval;
m_value = float(newval);
}
if (str != nullptr)
{
*str = string_format(m_format, *val_ptr);
*str = string_format(m_format, as_int());
}
return *val_ptr;
return as_int();
}
default:

View File

@ -51,8 +51,8 @@ public:
// Getters
std::string name() const { return m_name; }
slider_type type() const { return m_type; }
int32_t value() const { return m_value; }
float uniform_value() const { return *(reinterpret_cast<const float*>(&m_value)); }
float value() const { return m_value; }
float uniform_value() const { return float(m_value); }
slider_state* core_slider() const { return m_slider_state; }
size_t size() const { return get_size_for_type(m_type); }
@ -60,6 +60,7 @@ public:
protected:
slider_state* create_core_slider(running_machine &machine);
int32_t as_int() const { return int32_t(floor(m_value + 0.5f)); }
std::string m_name;
int32_t m_min;
@ -72,7 +73,7 @@ protected:
std::string m_format;
std::string m_description;
std::vector<std::string> m_strings;
int32_t m_value;
float m_value;
slider_state* m_slider_state;
};

View File

@ -39,7 +39,7 @@ bool bgfx_suppressor::suppress()
count = 3;
}
int32_t current_values[3];
float current_values[3];
for (int32_t index = 0; index < count; index++)
{
current_values[index] = m_sliders[index]->value();

Some files were not shown because too many files have changed in this diff Show More