trunk/hlsl/deconverge.fx
| r253016 | r253017 | |
| 1 | 1 | // license:BSD-3-Clause |
| 2 | | // copyright-holders:Ryan Holtz |
| 2 | // copyright-holders:Ryan Holtz,ImJezze |
| 3 | 3 | //----------------------------------------------------------------------------- |
| 4 | 4 | // Deconvergence Effect |
| 5 | 5 | //----------------------------------------------------------------------------- |
| r253016 | r253017 | |
| 29 | 29 | { |
| 30 | 30 | float4 Position : POSITION; |
| 31 | 31 | 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; |
| 38 | 34 | }; |
| 39 | 35 | |
| 40 | 36 | struct VS_INPUT |
| r253016 | r253017 | |
| 42 | 38 | float4 Position : POSITION; |
| 43 | 39 | float4 Color : COLOR0; |
| 44 | 40 | float2 TexCoord : TEXCOORD0; |
| 45 | | float2 Unused : TEXCOORD1; |
| 46 | 41 | }; |
| 47 | 42 | |
| 48 | 43 | struct PS_INPUT |
| 49 | 44 | { |
| 50 | 45 | 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; |
| 57 | 48 | }; |
| 58 | 49 | |
| 59 | 50 | //----------------------------------------------------------------------------- |
| 60 | 51 | // Deconvergence Vertex Shader |
| 61 | 52 | //----------------------------------------------------------------------------- |
| 62 | 53 | |
| 63 | | uniform float3 ConvergeX = float3(0.0f, 0.0f, 0.0f); |
| 64 | | uniform float3 ConvergeY = float3(0.0f, 0.0f, 0.0f); |
| 65 | | |
| 66 | 54 | uniform float2 ScreenDims; |
| 67 | 55 | uniform float2 SourceDims; |
| 68 | 56 | uniform float2 SourceRect; |
| 57 | uniform float2 TargetDims; |
| 58 | uniform float2 QuadDims; |
| 69 | 59 | |
| 60 | uniform bool SwapXY = false; |
| 61 | |
| 62 | uniform float3 ConvergeX = float3(0.0f, 0.0f, 0.0f); |
| 63 | uniform float3 ConvergeY = float3(0.0f, 0.0f, 0.0f); |
| 70 | 64 | uniform float3 RadialConvergeX = float3(0.0f, 0.0f, 0.0f); |
| 71 | 65 | uniform float3 RadialConvergeY = float3(0.0f, 0.0f, 0.0f); |
| 72 | 66 | |
| 73 | | uniform float Prescale; |
| 74 | | |
| 75 | 67 | VS_OUTPUT vs_main(VS_INPUT Input) |
| 76 | 68 | { |
| 77 | 69 | VS_OUTPUT Output = (VS_OUTPUT)0; |
| 78 | 70 | |
| 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 | |
| 81 | 81 | Output.Position = float4(Input.Position.xyz, 1.0f); |
| 82 | 82 | 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 | |
| 86 | 90 | Output.Color = Input.Color; |
| 87 | | float2 TexCoord = Input.TexCoord; |
| 88 | 91 | |
| 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; |
| 96 | 94 | |
| 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; |
| 100 | 98 | |
| 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 | |
| 101 | 114 | return Output; |
| 102 | 115 | } |
| 103 | 116 | |
| r253016 | r253017 | |
| 107 | 120 | |
| 108 | 121 | float4 ps_main(PS_INPUT Input) : COLOR |
| 109 | 122 | { |
| 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; |
| 114 | 126 | |
| 115 | | return float4(RedTexel, GrnTexel, BluTexel, Alpha); |
| 127 | return float4(r, g, b, 1.0f); |
| 116 | 128 | } |
| 117 | 129 | |
| 118 | 130 | //----------------------------------------------------------------------------- |
trunk/src/osd/modules/render/d3d/d3dhlsl.cpp
| r253016 | r253017 | |
| 1797 | 1797 | int next_index = 0; |
| 1798 | 1798 | |
| 1799 | 1799 | next_index = vector_buffer_pass(rt, next_index, poly, vertnum); |
| 1800 | next_index = deconverge_pass(rt, next_index, poly, vertnum); |
| 1800 | 1801 | next_index = defocus_pass(rt, next_index, poly, vertnum); // 1st pass |
| 1801 | 1802 | next_index = defocus_pass(rt, next_index, poly, vertnum); // 2nd pass |
| 1802 | 1803 | next_index = phosphor_pass(rt, ct, next_index, poly, vertnum); |
| r253016 | r253017 | |
| 2424 | 2425 | static INT32 slider_defocus_x(running_machine &machine, void *arg, std::string *str, INT32 newval) |
| 2425 | 2426 | { |
| 2426 | 2427 | ((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); |
| 2428 | 2429 | } |
| 2429 | 2430 | |
| 2430 | 2431 | static INT32 slider_defocus_y(running_machine &machine, void *arg, std::string *str, INT32 newval) |
| 2431 | 2432 | { |
| 2432 | 2433 | ((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); |
| 2434 | 2435 | } |
| 2435 | 2436 | |
| 2436 | 2437 | static INT32 slider_red_converge_x(running_machine &machine, void *arg, std::string *str, INT32 newval) |
| r253016 | r253017 | |
| 2798 | 2799 | { "Scanline Brightness", 0, 20, 40, 1, 5, slider_scanline_bright_scale }, |
| 2799 | 2800 | { "Scanline Brightness Overdrive", 0, 0, 20, 1, 5, slider_scanline_bright_offset }, |
| 2800 | 2801 | { "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 }, |
| 2815 | 2816 | { "Red Output from Red Input", -400, 0, 400, 5, 7, slider_red_from_r }, |
| 2816 | 2817 | { "Red Output from Green Input", -400, 0, 400, 5, 7, slider_red_from_g }, |
| 2817 | 2818 | { "Red Output from Blue Input", -400, 0, 400, 5, 7, slider_red_from_b }, |