mirror of
https://github.com/holub/mame
synced 2025-10-04 08:28:39 +03:00
Get bgfx post-processing working with laserdisc games, nw
This commit is contained in:
parent
5cab7dbd8b
commit
d9153eb306
@ -7,17 +7,10 @@
|
||||
}
|
||||
],
|
||||
"passes": [
|
||||
{ "effect": "default/blit",
|
||||
"name": "Copy To Unstretched Texture",
|
||||
"input": [
|
||||
{ "sampler": "s_tex", "texture": "screen" }
|
||||
],
|
||||
"output": "temp"
|
||||
},
|
||||
{ "effect": "default/blit",
|
||||
"name": "Final Upscale",
|
||||
"input": [
|
||||
{ "sampler": "s_tex", "target": "temp" }
|
||||
{ "sampler": "s_tex", "texture": "screen" }
|
||||
],
|
||||
"output": "output"
|
||||
}
|
||||
|
@ -87,9 +87,9 @@
|
||||
|
||||
{ "type": "vec2", "name": "defocus", "text": "Defocus, ", "default": [ 15, 15 ], "max": [ 500, 500 ], "min": [ 0, 0 ], "step": 1, "scale": 0.1, "format": "%2.1f", "screen": "crt" },
|
||||
|
||||
{ "type": "color", "name": "phosphor", "text": "Phosphor Persistence, ", "default": [ 55, 55, 55 ], "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": 6, "max": 100, "min": 0, "step": 1, "scale": 0.01, "format": "%1.2f", "screen": "crt" },
|
||||
{ "type": "float", "name": "scanline_alpha", "text": "Scanline Amount", "default": 60, "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": 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" },
|
||||
@ -175,15 +175,6 @@
|
||||
|
||||
// passes (required): The list of individual shaders to invoke, and any dynamic input parameters they need.
|
||||
"passes": [
|
||||
{
|
||||
// See the pass after this one for a verbose explanation of each parameter.
|
||||
"effect": "hlsl/blit",
|
||||
"name": "NTSC Blit to bilinear-able target",
|
||||
"input": [
|
||||
{ "sampler": "s_tex", "texture": "screen" }
|
||||
],
|
||||
"output": "ntsc"
|
||||
},
|
||||
{
|
||||
// effect (required): The name of the effect JSON file to load for this pass.
|
||||
// value: Any valid JSON filename included in your shader chain, without the extension.
|
||||
@ -261,7 +252,7 @@
|
||||
//
|
||||
// option (optional): The name of any MAME option, which will have its value fetched and used as the name of a PNG to load from the artwork directory.
|
||||
// value: Any valid MAME INI option name.
|
||||
{ "sampler": "s_tex", "target": "ntsc" }
|
||||
{ "sampler": "s_tex", "texture": "screen" }
|
||||
],
|
||||
|
||||
// output (required): The target to use as the output for this pass. Can be one of the named targets in "targets", or "output"
|
||||
@ -290,7 +281,8 @@
|
||||
{ "uniform": "u_jitter_amount", "parameter": "jitter" }
|
||||
],
|
||||
"input": [
|
||||
{ "sampler": "s_tex", "target": "ntsc" }
|
||||
{ "sampler": "s_tex", "target": "ntsc" },
|
||||
{ "sampler": "s_screen", "texture": "screen" }
|
||||
],
|
||||
"output": "guest"
|
||||
},
|
||||
@ -301,7 +293,7 @@
|
||||
{ "type": "slider", "condition": "notequal", "combine": "and", "name": "ntsc", "value": 0 }
|
||||
],
|
||||
"input": [
|
||||
{ "sampler": "s_tex", "target": "screen" }
|
||||
{ "sampler": "s_tex", "texture": "screen" }
|
||||
],
|
||||
"output": "guest"
|
||||
},
|
||||
|
@ -16,15 +16,15 @@
|
||||
"equation": "add",
|
||||
|
||||
// blend function parameters (optional): What factors to use in the blend function when calculating the final pixel.
|
||||
// values: "0", "1", "srcColor", "1-srcColor", "dstColor", "1-dstColor", "srcAlpha", "1-srcAlpha", "dstAlpha", "1-dstAlpha"
|
||||
// values: "0", "1", "srccolor", "1-srccolor", "dstcolor", "1-dstcolor", "srcalpha", "1-srcalpha", "dstalpha", "1-dstalpha"
|
||||
// defaults (srcColor, srcAlpha): "1"
|
||||
// defaults (dstColor, dstAlpha): "0"
|
||||
//
|
||||
// "zero", "one", "invSrcColor", "invDstColor", "invSrcAlpha", and "invDstAlpha" are provided as aliases for "0", "1", "1-srcColor", "1-dstColor", "1-srcAlpha", and "1-dstAlpha"
|
||||
"srcColor": "1",
|
||||
"dstColor": "0",
|
||||
"srcAlpha": "1",
|
||||
"dstAlpha": "0"
|
||||
// "zero", "one", "invsrccolor", "invdstcolor", "invsrcalpha", and "invdstalpha" are provided as aliases for "0", "1", "1-srccolor", "1-dstcolor", "1-srcalpha", and "1-dstalpha"
|
||||
"srcColor": "srcalpha",
|
||||
"dstColor": "1-srcalpha",
|
||||
"srcAlpha": "srcalpha",
|
||||
"dstAlpha": "1-srcalpha"
|
||||
},
|
||||
|
||||
// depth (required): The depth state for this effect.
|
||||
|
@ -16,15 +16,15 @@
|
||||
"equation": "add",
|
||||
|
||||
// blend function parameters (optional): What factors to use in the blend function when calculating the final pixel.
|
||||
// values: "0", "1", "srcColor", "1-srcColor", "dstColor", "1-dstColor", "srcAlpha", "1-srcAlpha", "dstAlpha", "1-dstAlpha"
|
||||
// values: "0", "1", "srccolor", "1-srccolor", "dstcolor", "1-dstcolor", "srcalpha", "1-srcalpha", "dstalpha", "1-dstalpha"
|
||||
// defaults (srcColor, srcAlpha): "1"
|
||||
// defaults (dstColor, dstAlpha): "0"
|
||||
//
|
||||
// "zero", "one", "invSrcColor", "invDstColor", "invSrcAlpha", and "invDstAlpha" are provided as aliases for "0", "1", "1-srcColor", "1-dstColor", "1-srcAlpha", and "1-dstAlpha"
|
||||
"srcColor": "1",
|
||||
"dstColor": "0",
|
||||
"srcAlpha": "1",
|
||||
"dstAlpha": "0"
|
||||
// "zero", "one", "invsrccolor", "invdstcolor", "invsrcalpha", and "invdstalpha" are provided as aliases for "0", "1", "1-srccolor", "1-dstcolor", "1-srcalpha", and "1-dstalpha"
|
||||
"srcColor": "srcalpha",
|
||||
"dstColor": "1-srcalpha",
|
||||
"srcAlpha": "srcalpha",
|
||||
"dstAlpha": "1-srcalpha"
|
||||
},
|
||||
|
||||
// depth (required): The depth state for this effect.
|
||||
|
@ -8,10 +8,10 @@
|
||||
{
|
||||
"blend": {
|
||||
"equation": "add",
|
||||
"srcColor": "1",
|
||||
"dstColor": "0",
|
||||
"srcAlpha": "1",
|
||||
"dstAlpha": "0"
|
||||
"srcColor": "srcalpha",
|
||||
"dstColor": "1-srcalpha",
|
||||
"srcAlpha": "srcalpha",
|
||||
"dstAlpha": "1-srcalpha"
|
||||
},
|
||||
"depth": {
|
||||
"function": "always"
|
||||
|
@ -9,10 +9,10 @@
|
||||
{
|
||||
"blend": {
|
||||
"equation": "add",
|
||||
"srcColor": "1",
|
||||
"dstColor": "0",
|
||||
"srcAlpha": "1",
|
||||
"dstAlpha": "0"
|
||||
"srcColor": "srcalpha",
|
||||
"dstColor": "1-srcalpha",
|
||||
"srcAlpha": "srcalpha",
|
||||
"dstAlpha": "1-srcalpha"
|
||||
},
|
||||
"depth": {
|
||||
"function": "always"
|
||||
|
@ -8,10 +8,10 @@
|
||||
{
|
||||
"blend": {
|
||||
"equation": "add",
|
||||
"srcColor": "1",
|
||||
"dstColor": "0",
|
||||
"srcAlpha": "1",
|
||||
"dstAlpha": "0"
|
||||
"srcColor": "srcalpha",
|
||||
"dstColor": "1-srcalpha",
|
||||
"srcAlpha": "srcalpha",
|
||||
"dstAlpha": "1-srcalpha"
|
||||
},
|
||||
"depth": {
|
||||
"function": "always"
|
||||
|
@ -9,10 +9,10 @@
|
||||
{
|
||||
"blend": {
|
||||
"equation": "add",
|
||||
"srcColor": "1",
|
||||
"dstColor": "0",
|
||||
"srcAlpha": "1",
|
||||
"dstAlpha": "0"
|
||||
"srcColor": "srcalpha",
|
||||
"dstColor": "1-srcalpha",
|
||||
"srcAlpha": "srcalpha",
|
||||
"dstAlpha": "1-srcalpha"
|
||||
},
|
||||
"depth": {
|
||||
"function": "always"
|
||||
|
@ -26,6 +26,7 @@
|
||||
"fragment": "fs_ntsc_decode",
|
||||
"uniforms": [
|
||||
{ "name": "s_tex", "type": "int", "values": [ 1.0 ] },
|
||||
{ "name": "s_screen", "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 ] },
|
||||
|
@ -9,10 +9,10 @@
|
||||
{
|
||||
"blend": {
|
||||
"equation": "add",
|
||||
"srcColor": "1",
|
||||
"dstColor": "0",
|
||||
"srcAlpha": "1",
|
||||
"dstAlpha": "0"
|
||||
"srcColor": "srcalpha",
|
||||
"dstColor": "1-srcalpha",
|
||||
"srcAlpha": "srcalpha",
|
||||
"dstAlpha": "1-srcalpha"
|
||||
},
|
||||
"depth": {
|
||||
"function": "always"
|
||||
|
@ -9,10 +9,10 @@
|
||||
{
|
||||
"blend": {
|
||||
"equation": "add",
|
||||
"srcColor": "1",
|
||||
"dstColor": "0",
|
||||
"srcAlpha": "1",
|
||||
"dstAlpha": "0"
|
||||
"srcColor": "srcalpha",
|
||||
"dstColor": "1-srcalpha",
|
||||
"srcAlpha": "srcalpha",
|
||||
"dstAlpha": "1-srcalpha"
|
||||
},
|
||||
"depth": {
|
||||
"function": "always"
|
||||
|
@ -9,10 +9,10 @@
|
||||
{
|
||||
"blend": {
|
||||
"equation": "add",
|
||||
"srcColor": "1",
|
||||
"dstColor": "0",
|
||||
"srcAlpha": "1",
|
||||
"dstAlpha": "0"
|
||||
"srcColor": "srcalpha",
|
||||
"dstColor": "1-srcalpha",
|
||||
"srcAlpha": "srcalpha",
|
||||
"dstAlpha": "1-srcalpha"
|
||||
},
|
||||
"depth": {
|
||||
"function": "always"
|
||||
|
@ -9,10 +9,10 @@
|
||||
{
|
||||
"blend": {
|
||||
"equation": "add",
|
||||
"srcColor": "1",
|
||||
"dstColor": "0",
|
||||
"srcAlpha": "1",
|
||||
"dstAlpha": "0"
|
||||
"srcColor": "srcalpha",
|
||||
"dstColor": "1-srcalpha",
|
||||
"srcAlpha": "srcalpha",
|
||||
"dstAlpha": "1-srcalpha"
|
||||
},
|
||||
"depth": {
|
||||
"function": "always"
|
||||
|
@ -16,15 +16,15 @@
|
||||
"equation": "add",
|
||||
|
||||
// blend function parameters (optional): What factors to use in the blend function when calculating the final pixel.
|
||||
// values: "0", "1", "srcColor", "1-srcColor", "dstColor", "1-dstColor", "srcAlpha", "1-srcAlpha", "dstAlpha", "1-dstAlpha"
|
||||
// values: "0", "1", "srccolor", "1-srccolor", "dstcolor", "1-dstcolor", "srcalpha", "1-srcalpha", "dstalpha", "1-dstalpha"
|
||||
// defaults (srcColor, srcAlpha): "1"
|
||||
// defaults (dstColor, dstAlpha): "0"
|
||||
//
|
||||
// "zero", "one", "invSrcColor", "invDstColor", "invSrcAlpha", and "invDstAlpha" are provided as aliases for "0", "1", "1-srcColor", "1-dstColor", "1-srcAlpha", and "1-dstAlpha"
|
||||
"srcColor": "1",
|
||||
"dstColor": "0",
|
||||
"srcAlpha": "1",
|
||||
"dstAlpha": "0"
|
||||
// "zero", "one", "invsrccolor", "invdstcolor", "invsrcalpha", and "invdstalpha" are provided as aliases for "0", "1", "1-srccolor", "1-dstcolor", "1-srcalpha", and "1-dstalpha"
|
||||
"srcColor": "srcalpha",
|
||||
"dstColor": "1-srcalpha",
|
||||
"srcAlpha": "srcalpha",
|
||||
"dstAlpha": "1-srcalpha"
|
||||
},
|
||||
|
||||
// depth (required): The depth state for this effect.
|
||||
|
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.
@ -146,6 +146,16 @@ void bgfx_chain_entry::setup_quaddims_uniform(render_primitive* prim) const
|
||||
}
|
||||
}
|
||||
|
||||
void bgfx_chain_entry::setup_screenindex_uniform(int32_t screen) const
|
||||
{
|
||||
bgfx_uniform* screen_index = m_effect->uniform("u_screen_index");
|
||||
if (screen_index != nullptr)
|
||||
{
|
||||
float values[1] = { float(screen) };
|
||||
screen_index->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, int32_t screen)
|
||||
{
|
||||
setup_screensize_uniforms(textures, screen_width, screen_height, screen);
|
||||
@ -153,6 +163,7 @@ void bgfx_chain_entry::setup_auto_uniforms(render_primitive* prim, texture_manag
|
||||
setup_rotationtype_uniform(rotation_type);
|
||||
setup_swapxy_uniform(swap_xy);
|
||||
setup_quaddims_uniform(prim);
|
||||
setup_screenindex_uniform(screen);
|
||||
}
|
||||
|
||||
bool bgfx_chain_entry::setup_view(int view, uint16_t screen_width, uint16_t screen_height, int32_t screen) const
|
||||
|
@ -49,6 +49,7 @@ private:
|
||||
void setup_rotationtype_uniform(uint32_t rotation_type) const;
|
||||
void setup_swapxy_uniform(bool swap_xy) const;
|
||||
void setup_quaddims_uniform(render_primitive* prim) const;
|
||||
void setup_screenindex_uniform(int32_t screen) const;
|
||||
|
||||
bool setup_view(int view, uint16_t screen_width, uint16_t screen_height, int32_t screen) const;
|
||||
void put_screen_buffer(render_primitive* prim, bgfx::TransientVertexBuffer* buffer) const;
|
||||
|
@ -1,4 +1,4 @@
|
||||
$input v_color0, v_texcoord0, v_texcoord1, v_texcoord2
|
||||
$input v_color0, v_texcoord0, v_texcoord1, v_texcoord2, v_texcoord3
|
||||
|
||||
// license:BSD-3-Clause
|
||||
// copyright-holders:Ryan Holtz,ImJezze
|
||||
@ -13,8 +13,9 @@ SAMPLER2D(s_tex, 0);
|
||||
|
||||
void main()
|
||||
{
|
||||
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;
|
||||
float a = texture2D(s_tex, v_texcoord0).a;
|
||||
float r = texture2D(s_tex, v_texcoord1).r;
|
||||
float g = texture2D(s_tex, v_texcoord2).g;
|
||||
float b = texture2D(s_tex, v_texcoord3).b;
|
||||
gl_FragColor = vec4(r, g, b, a) * v_color0;
|
||||
}
|
||||
|
@ -46,5 +46,6 @@ void main()
|
||||
|
||||
vec4 blurred = (d0 + d1 + d2 + d3 + d4 + d5 + d6 + d7 + d8) / 9.0;
|
||||
|
||||
gl_FragColor = vec4(blurred.rgb, 1.0) * v_color0;
|
||||
blurred.a = blurred.a + d0.a;
|
||||
gl_FragColor = blurred * v_color0;
|
||||
}
|
||||
|
@ -188,12 +188,14 @@ void main()
|
||||
|
||||
// Color
|
||||
vec4 BaseColor = texture2D(s_tex, BaseCoord);
|
||||
BaseColor.a = 1.0;
|
||||
|
||||
// Clamp
|
||||
if (BaseCoord.x > 1.0 || BaseCoord.y > 1.0 || BaseCoord.x < 0.0 || BaseCoord.y < 0.0)
|
||||
BaseColor.rgb = vec3(0.0, 0.0, 0.0);
|
||||
|
||||
{
|
||||
gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Vignetting Simulation
|
||||
vec2 VignetteCoord = BaseCoordCentered;
|
||||
|
||||
@ -201,14 +203,14 @@ void main()
|
||||
BaseColor.rgb *= VignetteFactor;
|
||||
|
||||
// Light Reflection Simulation
|
||||
vec3 LightColor = vec3(1.0, 0.90, 0.80); // color temperature 5.000 Kelvin
|
||||
vec4 LightColor = vec4(1.0, 0.90, 0.80, 1.0); // color temperature 5.000 Kelvin
|
||||
|
||||
vec2 SpotCoord = BaseCoordCentered;
|
||||
vec2 NoiseCoord = BaseCoordCentered;
|
||||
|
||||
float SpotAddend = GetSpotAddend(SpotCoord, u_reflection.x);
|
||||
float NoiseFactor = GetNoiseFactor(SpotAddend, rand(NoiseCoord));
|
||||
BaseColor.rgb += SpotAddend * NoiseFactor * LightColor;
|
||||
BaseColor += SpotAddend * NoiseFactor * LightColor;
|
||||
|
||||
// Round Corners Simulation
|
||||
vec2 RoundCornerCoord = BaseCoordCentered;
|
||||
@ -217,4 +219,5 @@ void main()
|
||||
BaseColor.rgb *= roundCornerFactor;
|
||||
|
||||
gl_FragColor = BaseColor;
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ uniform vec4 u_jitter_amount;
|
||||
|
||||
// Samplers
|
||||
SAMPLER2D(s_tex, 0);
|
||||
SAMPLER2D(s_screen, 1);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Constants
|
||||
@ -35,7 +36,7 @@ SAMPLER2D(s_tex, 0);
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 BaseTexel = texture2D(s_tex, v_texcoord0.xy);
|
||||
vec4 BaseTexel = texture2D(s_screen, 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);
|
||||
|
@ -1,4 +1,4 @@
|
||||
$input v_color0, v_texcoord0, v_texcoord1
|
||||
$input v_color0, v_texcoord0
|
||||
|
||||
// license:BSD-3-Clause
|
||||
// copyright-holders:Ryan Holtz,ImJezze
|
||||
@ -101,7 +101,6 @@ void main()
|
||||
|
||||
// Color
|
||||
vec4 BaseColor = texture2D(s_tex, BaseCoord);
|
||||
BaseColor.a = 1.0;
|
||||
|
||||
if (BaseCoord.x < 0.0 || BaseCoord.y < 0.0)
|
||||
{
|
||||
@ -155,5 +154,5 @@ void main()
|
||||
BaseColor.rgb *= HumBrightness;
|
||||
}
|
||||
|
||||
gl_FragColor = vec4(BaseColor.rgb * v_color0.rgb, 1.0);
|
||||
gl_FragColor = vec4(BaseColor.rgb * v_color0.rgb, BaseColor.a);
|
||||
}
|
||||
|
@ -26,5 +26,5 @@ void main()
|
||||
|
||||
vec2 TexCoord = (i + f) / u_source_dims.xy;
|
||||
|
||||
gl_FragColor = texture2D(s_tex, TexCoord) * v_color0;
|
||||
gl_FragColor = texture2D(s_tex, v_texcoord0.xy) * v_color0;
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ vec4 v_color0 : COLOR0 = vec4(1.0, 0.0, 0.0, 1.0);
|
||||
vec2 v_texcoord0 : TEXCOORD0 = vec2(0.0, 0.0);
|
||||
vec2 v_texcoord1 : TEXCOORD1 = vec2(0.0, 0.0);
|
||||
vec2 v_texcoord2 : TEXCOORD2 = vec2(0.0, 0.0);
|
||||
vec2 v_texcoord3 : TEXCOORD3 = vec2(0.0, 0.0);
|
||||
vec3 v_pos : TEXCOORD3 = vec3(0.0, 0.0, 0.0);
|
||||
|
||||
vec3 a_position : POSITION;
|
||||
|
@ -1,5 +1,5 @@
|
||||
$input a_position, a_texcoord0, a_color0
|
||||
$output v_color0, v_texcoord0, v_texcoord1, v_texcoord2
|
||||
$output v_color0, v_texcoord0, v_texcoord1, v_texcoord2, v_texcoord3
|
||||
|
||||
// license:BSD-3-Clause
|
||||
// copyright-holders:Dario Manesku
|
||||
@ -23,9 +23,10 @@ void main()
|
||||
|
||||
vec2 half_value = vec2(0.5, 0.5);
|
||||
|
||||
v_texcoord0 = (a_texcoord0 - half_value) * (1.0 + u_radial_converge_red.xy ) + half_value + u_converge_red.xy * (vec2(1.0, 1.0) / u_source_size.xy);
|
||||
v_texcoord1 = (a_texcoord0 - half_value) * (1.0 + u_radial_converge_green.xy) + half_value + u_converge_green.xy * (vec2(1.0, 1.0) / u_source_size.xy);
|
||||
v_texcoord2 = (a_texcoord0 - half_value) * (1.0 + u_radial_converge_blue.xy ) + half_value + u_converge_blue.xy * (vec2(1.0, 1.0) / u_source_size.xy);
|
||||
v_texcoord0 = a_texcoord0;
|
||||
v_texcoord1 = (a_texcoord0 - half_value) * (1.0 + u_radial_converge_red.xy ) + half_value + u_converge_red.xy * (vec2(1.0, 1.0) / u_source_size.xy);
|
||||
v_texcoord2 = (a_texcoord0 - half_value) * (1.0 + u_radial_converge_green.xy) + half_value + u_converge_green.xy * (vec2(1.0, 1.0) / u_source_size.xy);
|
||||
v_texcoord3 = (a_texcoord0 - half_value) * (1.0 + u_radial_converge_blue.xy ) + half_value + u_converge_blue.xy * (vec2(1.0, 1.0) / u_source_size.xy);
|
||||
|
||||
v_color0 = a_color0;
|
||||
}
|
||||
|
@ -1,19 +1,14 @@
|
||||
$input a_position, a_texcoord0, a_color0
|
||||
$output v_texcoord0, v_texcoord1, v_color0
|
||||
$output v_texcoord0, v_color0
|
||||
|
||||
// license:BSD-3-Clause
|
||||
// copyright-holders:Dario Manesku
|
||||
|
||||
#include "../../../../../../3rdparty/bgfx/examples/common/common.sh"
|
||||
|
||||
// Autos
|
||||
uniform vec4 u_source_dims;
|
||||
uniform vec4 u_screen_dims;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
|
||||
v_texcoord0 = a_texcoord0;
|
||||
v_texcoord1 = a_texcoord0.xy * u_source_dims.xy / u_screen_dims.x;
|
||||
v_color0 = a_color0;
|
||||
}
|
||||
|
@ -763,17 +763,33 @@ int renderer_bgfx::handle_screen_chains()
|
||||
|
||||
// Determine how many post-processing passes are needed
|
||||
int screens = 0;
|
||||
int total_screen_textures = 0;
|
||||
std::vector<void*> bases;
|
||||
while (prim != nullptr)
|
||||
{
|
||||
if (PRIMFLAG_GET_SCREENTEX(prim->flags))
|
||||
{
|
||||
total_screen_textures++;
|
||||
bool found = false;
|
||||
for (void* base : bases)
|
||||
{
|
||||
if (base == prim->texture.base)
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
screens++;
|
||||
bases.push_back(prim->texture.base);
|
||||
}
|
||||
}
|
||||
prim = prim->next();
|
||||
}
|
||||
|
||||
const uint32_t available_chains = m_screen_chains[window().m_index].size();
|
||||
screens = screens >= available_chains ? available_chains: screens;
|
||||
screens = screens >= available_chains ? available_chains : screens;
|
||||
|
||||
if (screens > 0)
|
||||
{
|
||||
@ -827,6 +843,7 @@ int renderer_bgfx::draw(int update)
|
||||
s_current_view = 0;
|
||||
}
|
||||
|
||||
m_seen_views.clear();
|
||||
m_ui_view = -1;
|
||||
|
||||
// Set view 0 default viewport.
|
||||
@ -857,7 +874,7 @@ int renderer_bgfx::draw(int update)
|
||||
bool atlas_valid = update_atlas();
|
||||
|
||||
render_primitive *prim = window().m_primlist->first();
|
||||
std::vector<screen_device*> screens;
|
||||
std::vector<void*> sources;
|
||||
while (prim != nullptr)
|
||||
{
|
||||
UINT32 blend = PRIMFLAG_GET_BLENDMODE(prim->flags);
|
||||
@ -868,16 +885,16 @@ int renderer_bgfx::draw(int update)
|
||||
int32_t screen = -1;
|
||||
if (PRIMFLAG_GET_SCREENTEX(prim->flags))
|
||||
{
|
||||
for (screen = 0; screen < screens.size(); screen++)
|
||||
for (screen = 0; screen < sources.size(); screen++)
|
||||
{
|
||||
if (screens[screen] == prim->container->screen())
|
||||
if (sources[screen] == prim->texture.base)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (screen == screens.size())
|
||||
if (screen == sources.size())
|
||||
{
|
||||
screens.push_back(prim->container->screen());
|
||||
sources.push_back(prim->texture.base);
|
||||
}
|
||||
}
|
||||
|
||||
@ -966,8 +983,17 @@ void renderer_bgfx::setup_view(uint32_t view_index, bool screen)
|
||||
|
||||
#if SCENE_VIEW
|
||||
if (view_index == m_max_view)
|
||||
#endif
|
||||
{
|
||||
#else
|
||||
while ((view_index + 1) > m_seen_views.size())
|
||||
{
|
||||
m_seen_views.push_back(false);
|
||||
}
|
||||
|
||||
if (!m_seen_views[view_index])
|
||||
{
|
||||
m_seen_views[view_index] = true;
|
||||
#endif
|
||||
bgfx::setViewClear(view_index, BGFX_CLEAR_COLOR | BGFX_CLEAR_DEPTH, 0x00000000, 1.0f, 0);
|
||||
}
|
||||
|
||||
|
@ -115,6 +115,7 @@ private:
|
||||
bgfx_effect* m_gui_effect[4];
|
||||
bgfx_effect* m_screen_effect[4];
|
||||
std::vector<std::vector<bgfx_chain*>> m_screen_chains;
|
||||
std::vector<uint32_t> m_seen_views;
|
||||
|
||||
std::map<UINT32, rectangle_packer::packed_rectangle> m_hash_to_entry;
|
||||
std::vector<rectangle_packer::packable_rectangle> m_texinfo;
|
||||
|
Loading…
Reference in New Issue
Block a user