summaryrefslogtreecommitdiffstatshomepage
path: root/hlsl/yiq_decode.fx
diff options
context:
space:
mode:
authorGravatarGravatar Ryan Holtz <rholtz@batcountryentertainment.com>2011-05-21 06:47:56 +0000
committerGravatarGravatar Ryan Holtz <rholtz@batcountryentertainment.com>2011-05-21 06:47:56 +0000
commita47bd09534ffb9e6a4165806fe5bf0859ab6b014 (patch)
tree8e14d76a88c068bd8c059b4277dd2ece2769ede0 /hlsl/yiq_decode.fx
parent62f733b93815bd60cfcaf60a2f99880a0ac029b4 (diff)
HLSL Improvements: [Ryan Holtz, Bat Country Entertainment]
- Added magnet deconvergence via a shader uniform - Improved phosphorescence - Improved YIQ codec
Diffstat (limited to 'hlsl/yiq_decode.fx')
-rw-r--r--hlsl/yiq_decode.fx78
1 files changed, 36 insertions, 42 deletions
diff --git a/hlsl/yiq_decode.fx b/hlsl/yiq_decode.fx
index 4fa190ed699..4419e9b2469 100644
--- a/hlsl/yiq_decode.fx
+++ b/hlsl/yiq_decode.fx
@@ -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;