Previous 199869 Revisions Next

r44505 Saturday 9th January, 2016 at 15:15:45 UTC by Jezze
Refactored color converge

- color converge is now independent from ratio
- the radial converge now "translates" the most outer pixel as thay
would be translated by the linar converge with the same amount
- color converge is now limited to a maximum of 10
- added color converge pass to vector rendering
[hlsl]deconverge.fx
[src/osd/modules/render/d3d]d3dhlsl.cpp

trunk/hlsl/deconverge.fx
r253016r253017
11// license:BSD-3-Clause
2// copyright-holders:Ryan Holtz
2// copyright-holders:Ryan Holtz,ImJezze
33//-----------------------------------------------------------------------------
44// Deconvergence Effect
55//-----------------------------------------------------------------------------
r253016r253017
2929{
3030   float4 Position : POSITION;
3131   float4 Color : COLOR0;
32   //float2 RedCoord : TEXCOORD0;
33   //float2 GrnCoord : TEXCOORD1;
34   //float2 BluCoord : TEXCOORD2;
35   float3 CoordX : TEXCOORD0;
36   float3 CoordY : TEXCOORD1;
37   float2 TexCoord : TEXCOORD2;
32   float3 TexCoordX : TEXCOORD0;
33   float3 TexCoordY : TEXCOORD1;
3834};
3935
4036struct VS_INPUT
r253016r253017
4238   float4 Position : POSITION;
4339   float4 Color : COLOR0;
4440   float2 TexCoord : TEXCOORD0;
45   float2 Unused : TEXCOORD1;
4641};
4742
4843struct PS_INPUT
4944{
5045   float4 Color : COLOR0;
51   //float2 RedCoord : TEXCOORD0;
52   //float2 GrnCoord : TEXCOORD1;
53   //float2 BluCoord : TEXCOORD2;
54   float3 CoordX : TEXCOORD0;
55   float3 CoordY : TEXCOORD1;
56   float2 TexCoord : TEXCOORD2;
46   float3 TexCoordX : TEXCOORD0;
47   float3 TexCoordY : TEXCOORD1;
5748};
5849
5950//-----------------------------------------------------------------------------
6051// Deconvergence Vertex Shader
6152//-----------------------------------------------------------------------------
6253
63uniform float3 ConvergeX = float3(0.0f, 0.0f, 0.0f);
64uniform float3 ConvergeY = float3(0.0f, 0.0f, 0.0f);
65
6654uniform float2 ScreenDims;
6755uniform float2 SourceDims;
6856uniform float2 SourceRect;
57uniform float2 TargetDims;
58uniform float2 QuadDims;
6959
60uniform bool SwapXY = false;
61
62uniform float3 ConvergeX = float3(0.0f, 0.0f, 0.0f);
63uniform float3 ConvergeY = float3(0.0f, 0.0f, 0.0f);
7064uniform float3 RadialConvergeX = float3(0.0f, 0.0f, 0.0f);
7165uniform float3 RadialConvergeY = float3(0.0f, 0.0f, 0.0f);
7266
73uniform float Prescale;
74
7567VS_OUTPUT vs_main(VS_INPUT Input)
7668{
7769   VS_OUTPUT Output = (VS_OUTPUT)0;
7870
79   float2 invDims = 1.0f / SourceDims;
80   float2 Ratios = SourceRect;
71   float2 HalfSourceRect = SourceRect * 0.5f;
72
73   float2 QuadRatio =
74      float2(1.0f, SwapXY
75         ? QuadDims.y / QuadDims.x
76         : QuadDims.x / QuadDims.y);
77
78   // imaginary texel dimensions independed from quad dimensions, but dependend on quad ratio
79   float2 FixedTexelDims = (1.0f / 1024.0) * SourceRect * QuadRatio;
80
8181   Output.Position = float4(Input.Position.xyz, 1.0f);
8282   Output.Position.xy /= ScreenDims;
83   Output.Position.y = 1.0f - Output.Position.y;
84   Output.Position.xy -= 0.5f;
85   Output.Position *= float4(2.0f, 2.0f, 1.0f, 1.0f);
83   Output.Position.y = 1.0f - Output.Position.y; // flip y
84   Output.Position.xy -= 0.5f; // center
85   Output.Position.xy *= 2.0f; // toom
86
87   float2 TexCoord = Input.TexCoord;
88   TexCoord += 0.5f / TargetDims; // half texel offset correction (DX9)
89   
8690   Output.Color = Input.Color;
87   float2 TexCoord = Input.TexCoord;
8891
89   float2 RadialRed = float2(RadialConvergeX.x, RadialConvergeY.x);
90   float2 RadialGrn = float2(RadialConvergeX.y, RadialConvergeY.y);
91   float2 RadialBlu = float2(RadialConvergeX.z, RadialConvergeY.z);
92   float2 ConvergeRed = float2(ConvergeX.x, ConvergeY.x);
93   float2 ConvergeGrn = float2(ConvergeX.y, ConvergeY.y);
94   float2 ConvergeBlu = float2(ConvergeX.z, ConvergeY.z);
95   float2 ScaledRatio = ((TexCoord * SourceRect) - 0.5f);
92   Output.TexCoordX = TexCoord.xxx;
93   Output.TexCoordY = TexCoord.yyy;
9694
97   Output.CoordX = ((((TexCoord.x / Ratios.x) - 0.5f)) * (1.0f + RadialConvergeX / SourceDims.x) + 0.5f) * Ratios.x + ConvergeX * invDims.x;
98   Output.CoordY = ((((TexCoord.y / Ratios.y) - 0.5f)) * (1.0f + RadialConvergeY / SourceDims.y) + 0.5f) * Ratios.y + ConvergeY * invDims.y;
99   Output.TexCoord = TexCoord;
95   // center coordinates
96   Output.TexCoordX -= HalfSourceRect.xxx;
97   Output.TexCoordY -= HalfSourceRect.yyy;
10098
99   // radial converge offset to "translate" the most outer pixel as thay would be translated by the linar converge with the same amount
100   float2 radialConvergeOffset = 2.0f / SourceRect;
101
102   // radial converge
103   Output.TexCoordX *= 1.0f + RadialConvergeX * FixedTexelDims.xxx * radialConvergeOffset.xxx;
104   Output.TexCoordY *= 1.0f + RadialConvergeY * FixedTexelDims.yyy * radialConvergeOffset.yyy;
105   
106   // un-center coordinates
107   Output.TexCoordX += HalfSourceRect.xxx;
108   Output.TexCoordY += HalfSourceRect.yyy;
109
110   // linear converge
111   Output.TexCoordX += ConvergeX * FixedTexelDims.xxx;
112   Output.TexCoordY += ConvergeY * FixedTexelDims.yyy;
113
101114   return Output;
102115}
103116
r253016r253017
107120
108121float4 ps_main(PS_INPUT Input) : COLOR
109122{
110   float Alpha = tex2D(DiffuseSampler, Input.TexCoord).a;
111   float RedTexel = tex2D(DiffuseSampler, float2(Input.CoordX.x, Input.CoordY.x)).r;
112   float GrnTexel = tex2D(DiffuseSampler, float2(Input.CoordX.y, Input.CoordY.y)).g;
113   float BluTexel = tex2D(DiffuseSampler, float2(Input.CoordX.z, Input.CoordY.z)).b;
123   float r = tex2D(DiffuseSampler, float2(Input.TexCoordX.x, Input.TexCoordY.x)).r;
124   float g = tex2D(DiffuseSampler, float2(Input.TexCoordX.y, Input.TexCoordY.y)).g;
125   float b = tex2D(DiffuseSampler, float2(Input.TexCoordX.z, Input.TexCoordY.z)).b;
114126
115   return float4(RedTexel, GrnTexel, BluTexel, Alpha);
127   return float4(r, g, b, 1.0f);
116128}
117129
118130//-----------------------------------------------------------------------------
trunk/src/osd/modules/render/d3d/d3dhlsl.cpp
r253016r253017
17971797      int next_index = 0;
17981798
17991799      next_index = vector_buffer_pass(rt, next_index, poly, vertnum);
1800      next_index = deconverge_pass(rt, next_index, poly, vertnum);
18001801      next_index = defocus_pass(rt, next_index, poly, vertnum); // 1st pass
18011802      next_index = defocus_pass(rt, next_index, poly, vertnum); // 2nd pass
18021803      next_index = phosphor_pass(rt, ct, next_index, poly, vertnum);
r253016r253017
24242425static INT32 slider_defocus_x(running_machine &machine, void *arg, std::string *str, INT32 newval)
24252426{
24262427   ((hlsl_options*)arg)->params_dirty = true;
2427   return slider_set(&(((hlsl_options*)arg)->defocus[0]), 0.5f, "%2.1f", str, newval);
2428   return slider_set(&(((hlsl_options*)arg)->defocus[0]), 0.1f, "%2.1f", str, newval);
24282429}
24292430
24302431static INT32 slider_defocus_y(running_machine &machine, void *arg, std::string *str, INT32 newval)
24312432{
24322433   ((hlsl_options*)arg)->params_dirty = true;
2433   return slider_set(&(((hlsl_options*)arg)->defocus[1]), 0.5f, "%2.1f", str, newval);
2434   return slider_set(&(((hlsl_options*)arg)->defocus[1]), 0.1f, "%2.1f", str, newval);
24342435}
24352436
24362437static INT32 slider_red_converge_x(running_machine &machine, void *arg, std::string *str, INT32 newval)
r253016r253017
27982799   { "Scanline Brightness",                 0,    20,    40, 1, 5, slider_scanline_bright_scale },
27992800   { "Scanline Brightness Overdrive",       0,     0,    20, 1, 5, slider_scanline_bright_offset },
28002801   { "Scanline Jitter",                     0,     0,    40, 1, 5, slider_scanline_offset },
2801   { "Defocus X",                           0,     0,    20, 1, 7, slider_defocus_x },
2802   { "Defocus Y",                           0,     0,    20, 1, 7, slider_defocus_y },
2803   { "Red Position Offset X",           -1500,     0,  1500, 1, 7, slider_red_converge_x },
2804   { "Red Position Offset Y",           -1500,     0,  1500, 1, 7, slider_red_converge_y },
2805   { "Green Position Offset X",         -1500,     0,  1500, 1, 7, slider_green_converge_x },
2806   { "Green Position Offset Y",         -1500,     0,  1500, 1, 7, slider_green_converge_y },
2807   { "Blue Position Offset X",          -1500,     0,  1500, 1, 7, slider_blue_converge_x },
2808   { "Blue Position Offset Y",          -1500,     0,  1500, 1, 7, slider_blue_converge_y },
2809   { "Red Convergence X",               -1500,     0,  1500, 1, 7, slider_red_radial_converge_x },
2810   { "Red Convergence Y",               -1500,     0,  1500, 1, 7, slider_red_radial_converge_y },
2811   { "Green Convergence X",             -1500,     0,  1500, 1, 7, slider_green_radial_converge_x },
2812   { "Green Convergence Y",             -1500,     0,  1500, 1, 7, slider_green_radial_converge_y },
2813   { "Blue Convergence X",              -1500,     0,  1500, 1, 7, slider_blue_radial_converge_x },
2814   { "Blue Convergence Y",              -1500,     0,  1500, 1, 7, slider_blue_radial_converge_y },
2802   { "Defocus X",                           0,     0,   100, 1, 7, slider_defocus_x },
2803   { "Defocus Y",                           0,     0,   100, 1, 7, slider_defocus_y },
2804   { "Red Position Offset X",            -100,     0,   100, 1, 7, slider_red_converge_x },
2805   { "Red Position Offset Y",            -100,     0,   100, 1, 7, slider_red_converge_y },
2806   { "Green Position Offset X",          -100,     0,   100, 1, 7, slider_green_converge_x },
2807   { "Green Position Offset Y",          -100,     0,   100, 1, 7, slider_green_converge_y },
2808   { "Blue Position Offset X",           -100,     0,   100, 1, 7, slider_blue_converge_x },
2809   { "Blue Position Offset Y",           -100,     0,   100, 1, 7, slider_blue_converge_y },
2810   { "Red Convergence X",                -100,     0,   100, 1, 7, slider_red_radial_converge_x },
2811   { "Red Convergence Y",                -100,     0,   100, 1, 7, slider_red_radial_converge_y },
2812   { "Green Convergence X",              -100,     0,   100, 1, 7, slider_green_radial_converge_x },
2813   { "Green Convergence Y",              -100,     0,   100, 1, 7, slider_green_radial_converge_y },
2814   { "Blue Convergence X",               -100,     0,   100, 1, 7, slider_blue_radial_converge_x },
2815   { "Blue Convergence Y",               -100,     0,   100, 1, 7, slider_blue_radial_converge_y },
28152816   { "Red Output from Red Input",        -400,     0,   400, 5, 7, slider_red_from_r },
28162817   { "Red Output from Green Input",      -400,     0,   400, 5, 7, slider_red_from_g },
28172818   { "Red Output from Blue Input",       -400,     0,   400, 5, 7, slider_red_from_b },


Previous 199869 Revisions Next


© 1997-2024 The MAME Team