mirror of
https://github.com/mamedev/mame.git
synced 2024-11-16 07:48:32 +01:00
HLSL Improvements: [Ryan Holtz, Bat Country Entertainment]
- Added magnet deconvergence via a shader uniform - Improved phosphorescence - Improved YIQ codec
This commit is contained in:
parent
62f733b938
commit
a47bd09534
5 changed files with 59 additions and 60 deletions
|
@ -26,6 +26,7 @@ struct VS_OUTPUT
|
|||
float2 RedCoord : TEXCOORD0;
|
||||
float2 GrnCoord : TEXCOORD1;
|
||||
float2 BluCoord : TEXCOORD2;
|
||||
float2 TexCoord : TEXCOORD3;
|
||||
};
|
||||
|
||||
struct VS_INPUT
|
||||
|
@ -42,6 +43,7 @@ struct PS_INPUT
|
|||
float2 RedCoord : TEXCOORD0;
|
||||
float2 GrnCoord : TEXCOORD1;
|
||||
float2 BluCoord : TEXCOORD2;
|
||||
float2 TexCoord : TEXCOORD3;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -86,18 +88,17 @@ VS_OUTPUT vs_main(VS_INPUT Input)
|
|||
Output.Position.y -= 0.5f;
|
||||
Output.Position *= float4(2.0f, 2.0f, 1.0f, 1.0f);
|
||||
Output.Color = Input.Color;
|
||||
float2 InvTexSize = float2(1.0f / TargetWidth, 1.0f / TargetHeight);
|
||||
float2 TexCoord = (Input.Position.xy * InvTexSize);
|
||||
TexCoord = TexCoord;// + float2(0.5f / TargetWidth, 0.5f / TargetHeight);// * float2(WidthRatio, HeightRatio);//(Input.TexCoord - float2(0.5f, 0.5f)) / 8.0f + float2(0.25f, 0.25f);
|
||||
float2 TexCoord = Input.TexCoord;
|
||||
|
||||
Output.RedCoord.x = ((((TexCoord.x / Ratios.x) - 0.5f)) * (1.0f + RedRadialConvergeX / RawWidth) + 0.5f) * Ratios.x + RedConvergeX * invDims.x;
|
||||
Output.GrnCoord.x = ((((TexCoord.x / Ratios.x) - 0.5f)) * (1.0f + GrnRadialConvergeX / RawWidth) + 0.5f) * Ratios.x + GrnConvergeX * invDims.x;
|
||||
Output.BluCoord.x = ((((TexCoord.x / Ratios.x) - 0.5f)) * (1.0f + BluRadialConvergeX / RawWidth) + 0.5f) * Ratios.x + GrnConvergeX * invDims.x;
|
||||
Output.BluCoord.x = ((((TexCoord.x / Ratios.x) - 0.5f)) * (1.0f + BluRadialConvergeX / RawWidth) + 0.5f) * Ratios.x + BluConvergeX * invDims.x;
|
||||
|
||||
Output.RedCoord.y = ((((TexCoord.y / Ratios.y) - 0.5f)) * (1.0f + RedRadialConvergeY / RawHeight) + 0.5f) * Ratios.y + RedConvergeY * invDims.y;
|
||||
Output.GrnCoord.y = ((((TexCoord.y / Ratios.y) - 0.5f)) * (1.0f + GrnRadialConvergeY / RawHeight) + 0.5f) * Ratios.y + BluConvergeY * invDims.y;
|
||||
Output.GrnCoord.y = ((((TexCoord.y / Ratios.y) - 0.5f)) * (1.0f + GrnRadialConvergeY / RawHeight) + 0.5f) * Ratios.y + GrnConvergeY * invDims.y;
|
||||
Output.BluCoord.y = ((((TexCoord.y / Ratios.y) - 0.5f)) * (1.0f + BluRadialConvergeY / RawHeight) + 0.5f) * Ratios.y + BluConvergeY * invDims.y;
|
||||
|
||||
|
||||
Output.TexCoord = TexCoord;
|
||||
return Output;
|
||||
}
|
||||
|
||||
|
@ -107,9 +108,14 @@ VS_OUTPUT vs_main(VS_INPUT Input)
|
|||
|
||||
float4 ps_main(PS_INPUT Input) : COLOR
|
||||
{
|
||||
float RedTexel = tex2D(DiffuseSampler, Input.RedCoord).r;
|
||||
float GrnTexel = tex2D(DiffuseSampler, Input.GrnCoord).g;
|
||||
float BluTexel = tex2D(DiffuseSampler, Input.BluCoord).b;
|
||||
float2 MagnetOffset = float2(32.0f / RawWidth, 32.0f / RawHeight);
|
||||
float2 MagnetCenter = float2(0.9f / WidthRatio, 0.9f / HeightRatio);
|
||||
float MagnetDistance = length((MagnetCenter - Input.TexCoord) * float2(WidthRatio, HeightRatio));
|
||||
float Deconverge = 1.0f - MagnetDistance / MagnetCenter;
|
||||
Deconverge = clamp(Deconverge, 0.0f, 1.0f);
|
||||
float RedTexel = tex2D(DiffuseSampler, lerp(Input.TexCoord, Input.RedCoord, Deconverge)).r;
|
||||
float GrnTexel = tex2D(DiffuseSampler, lerp(Input.TexCoord, Input.GrnCoord, Deconverge)).g;
|
||||
float BluTexel = tex2D(DiffuseSampler, lerp(Input.TexCoord, Input.BluCoord, Deconverge)).b;
|
||||
|
||||
return float4(RedTexel, GrnTexel, BluTexel, 1.0f);
|
||||
}
|
||||
|
|
|
@ -79,9 +79,7 @@ VS_OUTPUT vs_main(VS_INPUT Input)
|
|||
Output.Color = Input.Color;
|
||||
|
||||
float2 InvTexSize = float2(1.0f / TargetWidth, 1.0f / TargetHeight);
|
||||
Output.TexCoord = Input.Position.xy * InvTexSize;
|
||||
Output.TexCoord += 0.5f / float2(TargetWidth, TargetHeight);
|
||||
|
||||
Output.TexCoord = Input.TexCoord;
|
||||
Output.PrevCoord = Output.TexCoord;
|
||||
|
||||
return Output;
|
||||
|
|
|
@ -82,7 +82,9 @@ VS_OUTPUT vs_main(VS_INPUT Input)
|
|||
Output.Color = Input.Color;
|
||||
Output.TexCoord = Input.TexCoord;
|
||||
Output.ExtraInfo = Input.ExtraInfo;
|
||||
|
||||
|
||||
//Output.TexCoord /= 16.0f;
|
||||
//Output.TexCoord += 0.4875f;
|
||||
return Output;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,12 +23,12 @@ struct VS_OUTPUT
|
|||
{
|
||||
float4 Position : POSITION;
|
||||
float4 Color : COLOR0;
|
||||
float2 Coord0 : TEXCOORD0;
|
||||
float2 Coord1 : TEXCOORD1;
|
||||
float2 Coord2 : TEXCOORD2;
|
||||
float2 Coord3 : TEXCOORD3;
|
||||
float2 Coord4 : TEXCOORD4;
|
||||
float2 Coord5 : TEXCOORD5;
|
||||
float4 Coord0 : TEXCOORD0;
|
||||
float4 Coord1 : TEXCOORD1;
|
||||
float4 Coord2 : TEXCOORD2;
|
||||
float4 Coord3 : TEXCOORD3;
|
||||
float4 Coord4 : TEXCOORD4;
|
||||
float4 Coord5 : TEXCOORD5;
|
||||
};
|
||||
|
||||
struct VS_INPUT
|
||||
|
@ -42,12 +42,12 @@ struct VS_INPUT
|
|||
struct PS_INPUT
|
||||
{
|
||||
float4 Color : COLOR0;
|
||||
float2 Coord0 : TEXCOORD0;
|
||||
float2 Coord1 : TEXCOORD1;
|
||||
float2 Coord2 : TEXCOORD2;
|
||||
float2 Coord3 : TEXCOORD3;
|
||||
float2 Coord4 : TEXCOORD4;
|
||||
float2 Coord5 : TEXCOORD5;
|
||||
float4 Coord0 : TEXCOORD0;
|
||||
float4 Coord1 : TEXCOORD1;
|
||||
float4 Coord2 : TEXCOORD2;
|
||||
float4 Coord3 : TEXCOORD3;
|
||||
float4 Coord4 : TEXCOORD4;
|
||||
float4 Coord5 : TEXCOORD5;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -77,12 +77,12 @@ VS_OUTPUT vs_main(VS_INPUT Input)
|
|||
Output.Position.y -= 0.5f;
|
||||
Output.Position *= float4(2.0f, 2.0f, 1.0f, 1.0f);
|
||||
Output.Color = Input.Color;
|
||||
Output.Coord0 = Input.TexCoord + float2(0.00f / RawWidth, 0.0f);
|
||||
Output.Coord1 = Input.TexCoord + float2(0.25f / RawWidth, 0.0f);
|
||||
Output.Coord2 = Input.TexCoord + float2(0.50f / RawWidth, 0.0f);
|
||||
Output.Coord3 = Input.TexCoord + float2(0.75f / RawWidth, 0.0f);
|
||||
Output.Coord4 = Input.TexCoord + float2(1.00f / RawWidth, 0.0f);
|
||||
Output.Coord5 = Input.TexCoord + float2(1.25f / RawWidth, 0.0f);
|
||||
Output.Coord0.xy = Input.TexCoord + float2(-0.625f / RawWidth, 0.0f);
|
||||
Output.Coord1.xy = Input.TexCoord + float2(-0.375f / RawWidth, 0.0f);
|
||||
Output.Coord2.xy = Input.TexCoord + float2(-0.125f / RawWidth, 0.0f);
|
||||
Output.Coord3.xy = Input.TexCoord + float2(0.125f / RawWidth, 0.0f);
|
||||
Output.Coord4.xy = Input.TexCoord + float2(0.375f / RawWidth, 0.0f);
|
||||
Output.Coord5.xy = Input.TexCoord + float2(0.625f / RawWidth, 0.0f);
|
||||
|
||||
return Output;
|
||||
}
|
||||
|
@ -103,9 +103,9 @@ float4 ps_main(PS_INPUT Input) : COLOR
|
|||
{
|
||||
float2 RawDims = float2(RawWidth, RawHeight);
|
||||
float4 OrigC = tex2D(DiffuseSampler, Input.Coord0.xy);
|
||||
float4 OrigC2 = tex2D(DiffuseSampler, Input.Coord4.xy);
|
||||
float2 OrigC2 = tex2D(DiffuseSampler, Input.Coord4.xy);
|
||||
float4 C = OrigC;
|
||||
float4 C2 = OrigC2;
|
||||
float2 C2 = OrigC2;
|
||||
|
||||
float MaxC = 2.1183f;
|
||||
float MinC = -1.1183f;
|
||||
|
@ -114,35 +114,29 @@ float4 ps_main(PS_INPUT Input) : COLOR
|
|||
C = C * CRange + MinC;
|
||||
C2 = C2 * CRange + MinC;
|
||||
|
||||
float PI = 3.14159265f;
|
||||
|
||||
float2 Scaler = RawDims;
|
||||
float2 Coord0 = Input.Coord0.xy * Scaler;
|
||||
float2 Coord1 = Input.Coord1.xy * Scaler;
|
||||
float2 Coord2 = Input.Coord2.xy * Scaler;
|
||||
float2 Coord3 = Input.Coord3.xy * Scaler;
|
||||
float2 Coord4 = Input.Coord4.xy * Scaler;
|
||||
float2 Coord5 = Input.Coord5.xy * Scaler;
|
||||
float2 Coord0 = Input.Coord0.xy * RawDims;
|
||||
float2 Coord1 = Input.Coord1.xy * RawDims;
|
||||
float2 Coord2 = Input.Coord2.xy * RawDims;
|
||||
float2 Coord3 = Input.Coord3.xy * RawDims;
|
||||
float2 Coord4 = Input.Coord4.xy * RawDims;
|
||||
float2 Coord5 = Input.Coord5.xy * RawDims;
|
||||
|
||||
float W = WValue;
|
||||
float YRatio = 1.0f;
|
||||
float T0 = Coord0.x + AValue * YRatio * Coord0.y + BValue;
|
||||
float T1 = Coord1.x + AValue * YRatio * Coord1.y + BValue;
|
||||
float T2 = Coord2.x + AValue * YRatio * Coord2.y + BValue;
|
||||
float T3 = Coord3.x + AValue * YRatio * Coord3.y + BValue;
|
||||
float T4 = Coord4.x + AValue * YRatio * Coord4.y + BValue;
|
||||
float T5 = Coord5.x + AValue * YRatio * Coord5.y + BValue;
|
||||
float T0 = Coord0.x + AValue * Coord0.y + BValue;
|
||||
float T1 = Coord1.x + AValue * Coord1.y + BValue;
|
||||
float T2 = Coord2.x + AValue * Coord2.y + BValue;
|
||||
float T3 = Coord3.x + AValue * Coord3.y + BValue;
|
||||
float T4 = Coord4.x + AValue * Coord4.y + BValue;
|
||||
float T5 = Coord5.x + AValue * Coord5.y + BValue;
|
||||
float4 Tc = float4(T0, T1, T2, T3);
|
||||
float2 Tc2 = float2(T4, T5);
|
||||
|
||||
float Y = (C.r + C.g + C.b + C.a + C2.r + C2.g) / 6.0f;
|
||||
|
||||
float4 IQ = C;
|
||||
float4 I = IQ * sin(W * Tc);
|
||||
float4 Q = IQ * cos(W * Tc);
|
||||
float2 IQ2 = C2;
|
||||
float2 I2 = IQ2 * sin(W * Tc2);
|
||||
float2 Q2 = IQ2 * cos(W * Tc2);
|
||||
float4 I = C * sin(W * Tc);
|
||||
float4 Q = C * cos(W * Tc);
|
||||
float2 I2 = C2 * sin(W * Tc2);
|
||||
float2 Q2 = C2 * cos(W * Tc2);
|
||||
|
||||
float Iavg = (I.r + I.g + I.b + I.a + I2.r + I2.g) / 3.0f;
|
||||
float Qavg = (Q.r + Q.g + Q.b + Q.a + Q2.r + Q2.g) / 3.0f;
|
||||
|
|
|
@ -107,11 +107,10 @@ float4 ps_main(PS_INPUT Input) : COLOR
|
|||
float2 Coord3 = Input.Coord3.xy * Scaler;
|
||||
|
||||
float W = WValue;
|
||||
float YRatio = 1.0f;
|
||||
float T0 = Coord0.x + AValue * YRatio * Coord0.y + BValue;
|
||||
float T1 = Coord1.x + AValue * YRatio * Coord1.y + BValue;
|
||||
float T2 = Coord2.x + AValue * YRatio * Coord2.y + BValue;
|
||||
float T3 = Coord3.x + AValue * YRatio * Coord3.y + BValue;
|
||||
float T0 = Coord0.x + AValue * Coord0.y + BValue - 1.1f;
|
||||
float T1 = Coord1.x + AValue * Coord1.y + BValue - 1.1f;
|
||||
float T2 = Coord2.x + AValue * Coord2.y + BValue - 1.1f;
|
||||
float T3 = Coord3.x + AValue * Coord3.y + BValue - 1.1f;
|
||||
|
||||
float Y0 = dot(Texel0, float3(0.299f, 0.587f, 0.114f));
|
||||
float I0 = dot(Texel0, float3(0.595716f, -0.274453f, -0.321263f));
|
||||
|
|
Loading…
Reference in a new issue