diff options
Diffstat (limited to 'src/osd/modules/render/bgfx')
6 files changed, 126 insertions, 11 deletions
diff --git a/src/osd/modules/render/bgfx/chainentryreader.cpp b/src/osd/modules/render/bgfx/chainentryreader.cpp index 57ade646a44..156827b0a96 100644 --- a/src/osd/modules/render/bgfx/chainentryreader.cpp +++ b/src/osd/modules/render/bgfx/chainentryreader.cpp @@ -63,8 +63,10 @@ bgfx_chain_entry* chain_entry_reader::read_from_value(const Value& value, std::s if (!READER_CHECK(!has_target || input["target"].IsString(), (prefix + "input[" + std::to_string(i) + ": Value 'target' must be a string\n").c_str())) return nullptr; if (!READER_CHECK(!has_option || input["option"].IsString(), (prefix + "input[" + std::to_string(i) + ": Value 'option' must be a string\n").c_str())) return nullptr; if (!READER_CHECK(has_target || !input.HasMember("bilinear") || input["bilinear"].IsBool(), (prefix + "input[" + std::to_string(i) + ": Value 'bilinear' must be a boolean\n").c_str())) return nullptr; + if (!READER_CHECK(has_target || !input.HasMember("clamp") || input["clamp"].IsBool(), (prefix + "input[" + std::to_string(i) + ": Value 'clamp' must be a boolean\n").c_str())) return nullptr; if (!READER_CHECK(has_texture || has_option || !input.HasMember("selection") || input["selection"].IsString(), (prefix + "input[" + std::to_string(i) + ": Value 'selection' must be a string\n").c_str())) return nullptr; bool bilinear = get_bool(input, "bilinear", true); + bool clamp = get_bool(input, "clamp", false); std::string selection = get_string(input, "selection", ""); std::vector<std::string> texture_names; @@ -87,7 +89,8 @@ bgfx_chain_entry* chain_entry_reader::read_from_value(const Value& value, std::s if (selection == "") { // create texture for specified file name - uint32_t flags = bilinear ? 0 : (BGFX_TEXTURE_MIN_POINT | BGFX_TEXTURE_MAG_POINT | BGFX_TEXTURE_MIP_POINT); + uint32_t flags = bilinear ? 0u : (BGFX_TEXTURE_MIN_POINT | BGFX_TEXTURE_MAG_POINT | BGFX_TEXTURE_MIP_POINT); + flags |= clamp ? (BGFX_TEXTURE_U_CLAMP | BGFX_TEXTURE_V_CLAMP | BGFX_TEXTURE_W_CLAMP) : 0u; bgfx_texture* texture = chains.textures().create_png_texture(chains.options().art_path(), texture_name, texture_name, flags, screen_index); if (texture == nullptr) { @@ -97,7 +100,8 @@ bgfx_chain_entry* chain_entry_reader::read_from_value(const Value& value, std::s else { // create texture for specified file name - uint32_t flags = bilinear ? 0 : (BGFX_TEXTURE_MIN_POINT | BGFX_TEXTURE_MAG_POINT | BGFX_TEXTURE_MIP_POINT); + uint32_t flags = bilinear ? 0u : (BGFX_TEXTURE_MIN_POINT | BGFX_TEXTURE_MAG_POINT | BGFX_TEXTURE_MIP_POINT); + flags |= clamp ? (BGFX_TEXTURE_U_CLAMP | BGFX_TEXTURE_V_CLAMP | BGFX_TEXTURE_W_CLAMP) : 0u; bgfx_texture* texture = chains.textures().create_png_texture(chains.options().art_path(), texture_name, texture_name, flags, screen_index); if (texture == nullptr) { @@ -149,7 +153,8 @@ bgfx_chain_entry* chain_entry_reader::read_from_value(const Value& value, std::s if (file_extension == extension) { // create textures for all files containd in the path of the specified file name - uint32_t flags = bilinear ? 0 : (BGFX_TEXTURE_MIN_POINT | BGFX_TEXTURE_MAG_POINT | BGFX_TEXTURE_MIP_POINT); + uint32_t flags = bilinear ? 0u : (BGFX_TEXTURE_MIN_POINT | BGFX_TEXTURE_MAG_POINT | BGFX_TEXTURE_MIP_POINT); + flags |= clamp ? (BGFX_TEXTURE_U_CLAMP | BGFX_TEXTURE_V_CLAMP | BGFX_TEXTURE_W_CLAMP) : 0u; bgfx_texture* texture = chains.textures().create_png_texture(chains.options().art_path(), file_path, file_path, flags, screen_index); if (texture == nullptr) { diff --git a/src/osd/modules/render/bgfx/shaders/chains/hlsl/fs_chroma.sc b/src/osd/modules/render/bgfx/shaders/chains/hlsl/fs_chroma.sc new file mode 100644 index 00000000000..b76370c0aa9 --- /dev/null +++ b/src/osd/modules/render/bgfx/shaders/chains/hlsl/fs_chroma.sc @@ -0,0 +1,38 @@ +$input v_color0, v_texcoord0 + +// license: BSD-3-Clause +// copyright-holders: W. M. Martinez +//----------------------------------------------------------------------------- +// Phosphor Chromaticity to sRGB Transform Effect +//----------------------------------------------------------------------------- + +#include "common.sh" + +// User-supplied +uniform vec4 u_y_gain; +uniform vec4 u_chroma_a; +uniform vec4 u_chroma_b; +uniform vec4 u_chroma_c; + +// Samplers +SAMPLER2D(s_tex, 0); + +void main() +{ + vec4 cin = texture2D(s_tex, v_texcoord0); + vec4 cout = vec4(0.0, 0.0, 0.0, cin.a); + mat3 xy = mat3(u_chroma_a.xyz, u_chroma_b.xyz, u_chroma_c.xyz); + const mat3 XYZ_TO_sRGB = mat3( + 3.2406, -1.5372, -0.4986, + -0.9689, 1.8758, 0.0415, + 0.0557, -0.2040, 1.0570 + ); + + for (int i = 0; i < 3; ++i) { + float Y = u_y_gain[i] * cin[i]; + float X = xy[i].x / xy[i].y * Y; + float Z = (1.0 - xy[i].x - xy[i].y) / xy[i].y * Y; + cout.rgb += mul(XYZ_TO_sRGB, vec3(X, Y, Z)); + } + gl_FragColor = cout * v_color0; +} diff --git a/src/osd/modules/render/bgfx/shaders/chains/hlsl/fs_post.sc b/src/osd/modules/render/bgfx/shaders/chains/hlsl/fs_post.sc index 4aa3719c0ab..10fb11dac8c 100644 --- a/src/osd/modules/render/bgfx/shaders/chains/hlsl/fs_post.sc +++ b/src/osd/modules/render/bgfx/shaders/chains/hlsl/fs_post.sc @@ -3,11 +3,15 @@ $input v_color0, v_texcoord0 // license:BSD-3-Clause // copyright-holders:Ryan Holtz,ImJezze //----------------------------------------------------------------------------- -// Scanline & Shadowmask Effect +// Shadowmask Effect //----------------------------------------------------------------------------- #include "common.sh" +#define MONOCHROME 1.0 +#define DICHROME 2.0 +#define TRICHROME 3.0 + // Autos uniform vec4 u_swap_xy; uniform vec4 u_source_dims; // size of the guest machine @@ -27,6 +31,8 @@ uniform vec4 u_humbar_hertz_rate; // difference between the 59.94 Hz field rate uniform vec4 u_humbar_alpha; uniform vec4 u_power; uniform vec4 u_floor; +uniform vec4 u_chroma_mode; +uniform vec4 u_conversion_gain; // Parametric uniform vec4 u_time; // milliseconds @@ -112,6 +118,14 @@ void main() } else { + // Hum Bar Simulation + if (u_humbar_alpha.x > 0.0f) + { + float HumTimeStep = fract(u_time.x * u_humbar_hertz_rate.x); + float HumBrightness = 1.0 - fract(BaseCoord.y + HumTimeStep) * u_humbar_alpha.x; + BaseColor.rgb *= HumBrightness; + } + // Mask Simulation if (u_shadow_alpha.x > 0.0) { @@ -139,14 +153,15 @@ void main() BaseColor.g = pow(BaseColor.g, u_power.g); BaseColor.b = pow(BaseColor.b, u_power.b); - // Hum Bar Simulation - if (u_humbar_alpha.x > 0.0f) - { - float HumTimeStep = fract(u_time.x * u_humbar_hertz_rate.x); - float HumBrightness = 1.0 - fract(BaseCoord.y + HumTimeStep) * u_humbar_alpha.x; - BaseColor.rgb *= HumBrightness; + BaseColor.rgb *= v_color0.rgb; + if (u_chroma_mode.x == MONOCHROME) { + BaseColor.r = dot(u_conversion_gain.rgb, BaseColor.rgb); + BaseColor.gb = vec2(BaseColor.r, BaseColor.r); + } else if (u_chroma_mode.x == DICHROME) { + BaseColor.r = dot(u_conversion_gain.rg, BaseColor.rg); + BaseColor.g = BaseColor.r; } - gl_FragColor = vec4(BaseColor.rgb * v_color0.rgb, BaseColor.a); + gl_FragColor = BaseColor; } } diff --git a/src/osd/modules/render/bgfx/shaders/chains/hlsl/vs_chroma.sc b/src/osd/modules/render/bgfx/shaders/chains/hlsl/vs_chroma.sc new file mode 100644 index 00000000000..405ef8feb3b --- /dev/null +++ b/src/osd/modules/render/bgfx/shaders/chains/hlsl/vs_chroma.sc @@ -0,0 +1,14 @@ +$input a_position, a_texcoord0, a_color0 +$output v_texcoord0, v_color0 + +// license:BSD-3-Clause +// copyright-holders:Dario Manesku + +#include "common.sh" + +void main() +{ + gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0)); + v_texcoord0 = a_texcoord0; + v_color0 = a_color0; +} diff --git a/src/osd/modules/render/bgfx/shaders/chains/misc/fs_lut.sc b/src/osd/modules/render/bgfx/shaders/chains/misc/fs_lut.sc new file mode 100644 index 00000000000..2c8cffab7e1 --- /dev/null +++ b/src/osd/modules/render/bgfx/shaders/chains/misc/fs_lut.sc @@ -0,0 +1,29 @@ +$input v_color0, v_texcoord0 + +// license: BSD-3-Clause +// copyright-holders: W. M. Martinez + +#include "common.sh" + +#define LUT_TEXTURE_WIDTH 4096.0f +#define LUT_SIZE 64.0f +#define LUT_SCALE vec2(1.0f / LUT_TEXTURE_WIDTH, 1.0f / LUT_SIZE) + +SAMPLER2D(s_tex, 0); +SAMPLER2D(s_3dlut, 1); + +void main() +{ + vec4 bp = texture2D(s_tex, v_texcoord0); + vec3 color = bp.rgb; + // NOTE: Do not change the order of parameters here. + vec3 lutcoord = vec3(color.rg * ((LUT_SIZE - 1.0f) + 0.5f) * + LUT_SCALE, (LUT_SIZE - 1.0f) * color.b); + float shift = floor(lutcoord.z); + + lutcoord.x += shift * LUT_SCALE.y; + color.rgb = mix(texture2D(s_3dlut, lutcoord.xy).rgb, + texture2D(s_3dlut, vec2(lutcoord.x + LUT_SCALE.y, + lutcoord.y)).rgb, lutcoord.z - shift); + gl_FragColor = vec4(color, bp.a) * v_color0; +} diff --git a/src/osd/modules/render/bgfx/shaders/chains/misc/vs_lut.sc b/src/osd/modules/render/bgfx/shaders/chains/misc/vs_lut.sc new file mode 100644 index 00000000000..405ef8feb3b --- /dev/null +++ b/src/osd/modules/render/bgfx/shaders/chains/misc/vs_lut.sc @@ -0,0 +1,14 @@ +$input a_position, a_texcoord0, a_color0 +$output v_texcoord0, v_color0 + +// license:BSD-3-Clause +// copyright-holders:Dario Manesku + +#include "common.sh" + +void main() +{ + gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0)); + v_texcoord0 = a_texcoord0; + v_color0 = a_color0; +} |