diff options
author | 2013-08-29 00:56:33 +0000 | |
---|---|---|
committer | 2013-08-29 00:56:33 +0000 | |
commit | ac119a8e15e543535dc04c091b037aee2414a7c7 (patch) | |
tree | 83668932432f3acd9aa16f9e19ee0ec77ec8e96f /hlsl | |
parent | 8fe60e88317e344a8acaf6506486795515e88397 (diff) |
uniform consolidation, nw
Diffstat (limited to 'hlsl')
-rw-r--r-- | hlsl/color.fx | 5 | ||||
-rw-r--r-- | hlsl/deconverge.fx | 16 | ||||
-rw-r--r-- | hlsl/pincushion.fx | 9 | ||||
-rw-r--r-- | hlsl/post.fx | 16 | ||||
-rw-r--r-- | hlsl/prescale.fx | 1 | ||||
-rw-r--r-- | hlsl/yiq_decode.fx | 28 | ||||
-rw-r--r-- | hlsl/yiq_encode.fx | 21 |
7 files changed, 39 insertions, 57 deletions
diff --git a/hlsl/color.fx b/hlsl/color.fx index 728e88ab85f..d74f523fcc2 100644 --- a/hlsl/color.fx +++ b/hlsl/color.fx @@ -45,8 +45,7 @@ struct PS_INPUT //----------------------------------------------------------------------------- uniform float2 ScreenDims; - -uniform float2 RawDims; +uniform float2 SourceDims; uniform float YIQEnable; @@ -54,7 +53,7 @@ VS_OUTPUT vs_main(VS_INPUT Input) { VS_OUTPUT Output = (VS_OUTPUT)0; - float2 invDims = 1.0f / RawDims; + float2 invDims = 1.0f / SourceDims; Output.Position = float4(Input.Position.xyz, 1.0f); Output.Position.xy /= ScreenDims; Output.Position.y = 1.0f - Output.Position.y; diff --git a/hlsl/deconverge.fx b/hlsl/deconverge.fx index bcf3b2ee5a7..90653b2927a 100644 --- a/hlsl/deconverge.fx +++ b/hlsl/deconverge.fx @@ -58,10 +58,8 @@ uniform float3 ConvergeX = float3(0.0f, 0.0f, 0.0f); uniform float3 ConvergeY = float3(0.0f, 0.0f, 0.0f); uniform float2 ScreenDims; - -uniform float2 RawDims; - -uniform float2 SizeRatio; +uniform float2 SourceDims; +uniform float2 SourceRect; uniform float3 RadialConvergeX = float3(0.0f, 0.0f, 0.0f); uniform float3 RadialConvergeY = float3(0.0f, 0.0f, 0.0f); @@ -72,8 +70,8 @@ VS_OUTPUT vs_main(VS_INPUT Input) { VS_OUTPUT Output = (VS_OUTPUT)0; - float2 invDims = 1.0f / RawDims; - float2 Ratios = SizeRatio; + float2 invDims = 1.0f / SourceDims; + float2 Ratios = SourceRect; Output.Position = float4(Input.Position.xyz, 1.0f); Output.Position.xy /= ScreenDims; Output.Position.y = 1.0f - Output.Position.y; @@ -88,10 +86,10 @@ VS_OUTPUT vs_main(VS_INPUT Input) float2 ConvergeRed = float2(ConvergeX.x, ConvergeY.x); float2 ConvergeGrn = float2(ConvergeX.y, ConvergeY.y); float2 ConvergeBlu = float2(ConvergeX.z, ConvergeY.z); - float2 ScaledRatio = ((TexCoord * SizeRatio) - 0.5f); + float2 ScaledRatio = ((TexCoord * SourceRect) - 0.5f); - Output.CoordX = ((((TexCoord.x / Ratios.x) - 0.5f)) * (1.0f + RadialConvergeX / RawDims.x) + 0.5f) * Ratios.x + ConvergeX * invDims.x; - Output.CoordY = ((((TexCoord.y / Ratios.y) - 0.5f)) * (1.0f + RadialConvergeY / RawDims.y) + 0.5f) * Ratios.y + ConvergeY * invDims.y; + Output.CoordX = ((((TexCoord.x / Ratios.x) - 0.5f)) * (1.0f + RadialConvergeX / SourceDims.x) + 0.5f) * Ratios.x + ConvergeX * invDims.x; + Output.CoordY = ((((TexCoord.y / Ratios.y) - 0.5f)) * (1.0f + RadialConvergeY / SourceDims.y) + 0.5f) * Ratios.y + ConvergeY * invDims.y; Output.TexCoord = TexCoord; return Output; diff --git a/hlsl/pincushion.fx b/hlsl/pincushion.fx index 7e856c6ca26..45b1ef453ed 100644 --- a/hlsl/pincushion.fx +++ b/hlsl/pincushion.fx @@ -92,17 +92,14 @@ uniform float PI = 3.14159265f; uniform float PincushionAmountX = 0.1f; uniform float PincushionAmountY = 0.1f; -uniform float WidthRatio; -uniform float HeightRatio; +uniform float2 ActiveArea; float4 ps_main(PS_INPUT Input) : COLOR { - float2 Ratios = float2(WidthRatio, HeightRatio); - // -- Screen Pincushion Calculation -- - float2 UnitCoord = Input.TexCoord * Ratios * 2.0f - 1.0f; + float2 UnitCoord = Input.TexCoord * ActiveArea * 2.0f - 1.0f; - float PincushionR2 = pow(length(UnitCoord),2.0f) / pow(length(Ratios), 2.0f); + float PincushionR2 = pow(length(UnitCoord),2.0f) / pow(length(ActiveArea), 2.0f); float2 PincushionCurve = UnitCoord * PincushionAmountX * PincushionR2; float2 BaseCoord = Input.TexCoord + PincushionCurve; diff --git a/hlsl/post.fx b/hlsl/post.fx index e8213b345f2..0fb466926ba 100644 --- a/hlsl/post.fx +++ b/hlsl/post.fx @@ -59,9 +59,9 @@ struct PS_INPUT uniform float2 ScreenDims; -uniform float2 RawDims; +uniform float2 SourceDims; -uniform float2 SizeRatio; +uniform float2 SourceRect; VS_OUTPUT vs_main(VS_INPUT Input) { @@ -73,7 +73,7 @@ VS_OUTPUT vs_main(VS_INPUT Input) Output.Position.xy -= 0.5f; Output.Position *= float4(2.0f, 2.0f, 1.0f, 1.0f); Output.Color = Input.Color; - Output.TexCoord = Input.TexCoord + 0.5f / RawDims; + Output.TexCoord = Input.TexCoord + 0.5f / SourceDims; return Output; } @@ -110,7 +110,7 @@ uniform float3 Floor = float3(0.0f, 0.0f, 0.0f); float4 ps_main(PS_INPUT Input) : COLOR { - float2 Ratios = 1.0f / SizeRatio; + float2 Ratios = 1.0f / SourceRect; // -- Screen Pincushion Calculation -- float2 PinUnitCoord = Input.TexCoord * Ratios * 2.0f - 1.0f; @@ -145,12 +145,12 @@ float4 ps_main(PS_INPUT Input) : COLOR float4 BaseTexel = tex2D(DiffuseSampler, BaseCoord); // -- Alpha Clipping (1px border in drawd3d does not work for some reason) -- - clip((BaseCoord < 1.0f / RawDims) ? -1 : 1); - clip((BaseCoord > (SizeRatio + 1.0f / RawDims)) ? -1 : 1); + clip((BaseCoord < 1.0f / SourceDims) ? -1 : 1); + clip((BaseCoord > (SourceRect + 1.0f / SourceDims)) ? -1 : 1); // -- Scanline Simulation -- - float InnerSine = ScanCoord.y * RawDims.y * ScanlineScale; - float ScanBrightMod = sin(InnerSine * PI + ScanlineOffset * RawDims.y); + float InnerSine = ScanCoord.y * SourceDims.y * ScanlineScale; + float ScanBrightMod = sin(InnerSine * PI + ScanlineOffset * SourceDims.y); float3 ScanBrightness = lerp(1.0f, (pow(ScanBrightMod * ScanBrightMod, ScanlineHeight) * ScanlineBrightScale + 1.0f) * 0.5f, ScanlineAmount); float3 Scanned = BaseTexel.rgb * ScanBrightness; diff --git a/hlsl/prescale.fx b/hlsl/prescale.fx index c4aa19d86c0..1e60f0a7f77 100644 --- a/hlsl/prescale.fx +++ b/hlsl/prescale.fx @@ -42,7 +42,6 @@ struct PS_INPUT // Passthrough Vertex Shader //----------------------------------------------------------------------------- -uniform float2 RawDims; uniform float2 ScreenDims; VS_OUTPUT vs_main(VS_INPUT Input) diff --git a/hlsl/yiq_decode.fx b/hlsl/yiq_decode.fx index 2148178ec6f..00d5a6d721a 100644 --- a/hlsl/yiq_decode.fx +++ b/hlsl/yiq_decode.fx @@ -55,27 +55,21 @@ struct PS_INPUT // YIQ Decode Vertex Shader //----------------------------------------------------------------------------- -uniform float ScreenWidth; -uniform float ScreenHeight; - -uniform float2 RawDims; - -uniform float WidthRatio; -uniform float HeightRatio; +uniform float2 ScreenDims; +uniform float2 SourceDims; +uniform float2 SourceRect; VS_OUTPUT vs_main(VS_INPUT Input) { VS_OUTPUT Output = (VS_OUTPUT)0; Output.Position = float4(Input.Position.xyz, 1.0f); - Output.Position.x /= ScreenWidth; - Output.Position.y /= ScreenHeight; + Output.Position.xy /= ScreenDims; Output.Position.y = 1.0f - Output.Position.y; - Output.Position.x -= 0.5f; - Output.Position.y -= 0.5f; + Output.Position.xy -= 0.5f; Output.Position *= float4(2.0f, 2.0f, 1.0f, 1.0f); Output.Coord0.xy = Input.TexCoord; - Output.Coord0.zw = float2(1.0f / RawDims.x, 0.0f); + Output.Coord0.zw = float2(1.0f / SourceDims.x, 0.0f); return Output; } @@ -101,7 +95,7 @@ uniform float PI2 = 6.283185307178; float4 ps_main(PS_INPUT Input) : COLOR { - float4 BaseTexel = tex2D(DiffuseSampler, Input.Coord0.xy + 0.5f / RawDims); + float4 BaseTexel = tex2D(DiffuseSampler, Input.Coord0.xy + 0.5f / SourceDims); // YIQ convolution: N coefficients each float4 YAccum = 0.0f; @@ -110,7 +104,7 @@ float4 ps_main(PS_INPUT Input) : COLOR float MaxC = 2.1183f; float MinC = -1.1183f; float CRange = MaxC - MinC; - float FrameWidthx4 = RawDims.x * 4.0f / WidthRatio; + float FrameWidthx4 = SourceDims.x * 4.0f / SourceRect.x; float Fc_y1 = (CCValue - NotchHalfWidth) * ScanTime / FrameWidthx4; float Fc_y2 = (CCValue + NotchHalfWidth) * ScanTime / FrameWidthx4; float Fc_y3 = YFreqResponse * ScanTime / FrameWidthx4; @@ -130,14 +124,14 @@ float4 ps_main(PS_INPUT Input) : COLOR float4 NOffset = float4(0.0f, 1.0f, 2.0f, 3.0f); float W = PI2 * CCValue * ScanTime; float4 CoordY = Input.Coord0.y; - float4 VPosition = CoordY * (RawDims.x * WidthRatio); + float4 VPosition = (CoordY / SourceRect.y) * (SourceDims.x * SourceRect.x); for(float n = -41.0f; n < 42.0f; n += 4.0f) { float4 n4 = n + NOffset; float4 CoordX = Input.Coord0.x + Input.Coord0.z * n4 * 0.25f; float2 TexCoord = float2(CoordX.r, CoordY.r); - float4 C = tex2D(CompositeSampler, TexCoord + float2(0.5f, 0.0f) / RawDims) * CRange + MinC; - float4 WT = W * (CoordX * WidthRatio + VPosition + BValue) + OValue; + float4 C = tex2D(CompositeSampler, TexCoord + float2(0.5f, 0.0f) / SourceDims) * CRange + MinC; + float4 WT = W * (CoordX * SourceRect.x + VPosition + BValue) + OValue; float4 SincKernel = 0.54f + 0.46f * cos(PI2Length * n4); float4 SincYIn1 = Fc_y1_pi2 * n4; diff --git a/hlsl/yiq_encode.fx b/hlsl/yiq_encode.fx index 4c659511d54..f87141d689b 100644 --- a/hlsl/yiq_encode.fx +++ b/hlsl/yiq_encode.fx @@ -44,19 +44,16 @@ struct PS_INPUT // YIQ Encode Vertex Shader //----------------------------------------------------------------------------- -uniform float ScreenWidth; -uniform float ScreenHeight; +uniform float2 ScreenDims; VS_OUTPUT vs_main(VS_INPUT Input) { VS_OUTPUT Output = (VS_OUTPUT)0; Output.Position = float4(Input.Position.xyz, 1.0f); - Output.Position.x /= ScreenWidth; - Output.Position.y /= ScreenHeight; + Output.Position.xy /= ScreenDims; Output.Position.y = 1.0f - Output.Position.y; - Output.Position.x -= 0.5f; - Output.Position.y -= 0.5f; + Output.Position.xy -= 0.5f; Output.Position *= float4(2.0f, 2.0f, 1.0f, 1.0f); Output.Color = Input.Color; Output.TexCoord = Input.TexCoord; @@ -74,10 +71,8 @@ uniform float CCValue = 3.04183f; uniform float PValue = 1.0f; uniform float ScanTime = 52.6f; -uniform float2 RawDims; - -uniform float WidthRatio; -uniform float HeightRatio; +uniform float2 SourceDims; +uniform float2 SourceRect; uniform float4 YDot = float4(0.299f, 0.587f, 0.114f, 0.0f); uniform float4 IDot = float4(0.595716f, -0.274453f, -0.321263f, 0.0f); @@ -93,7 +88,7 @@ uniform float CRange = 3.2366f; float4 ps_main(PS_INPUT Input) : COLOR { - float2 InvDims = 1.0f / RawDims; + float2 InvDims = 1.0f / SourceDims; float4 CoordX = float4(Input.TexCoord.x + OffsetX * InvDims.x); float4 CoordY = Input.TexCoord.y; @@ -108,8 +103,8 @@ float4 ps_main(PS_INPUT Input) : COLOR float4 Q = float4(dot(Texel0, QDot), dot(Texel1, QDot), dot(Texel2, QDot), dot(Texel3, QDot)); float4 W = PI2 * CCValue * ScanTime; - float4 VPosition = CoordY * (RawDims.x * WidthRatio); - float4 T = CoordX * WidthRatio + VPosition + BValue; + float4 VPosition = (CoordY / SourceRect.y) * (SourceDims.x * SourceRect.x); + float4 T = CoordX * SourceRect.x + VPosition + BValue; float4 C = Y + I * cos(T * W) + Q * sin(T * W); C = (C - MinC) / CRange; |