summaryrefslogtreecommitdiffstatshomepage
path: root/hlsl
diff options
context:
space:
mode:
author Ryan Holtz <rholtz@batcountryentertainment.com>2011-05-31 05:02:17 +0000
committer Ryan Holtz <rholtz@batcountryentertainment.com>2011-05-31 05:02:17 +0000
commited6689e2d4934a8483a84ae65e1e8ac8a21c76e5 (patch)
tree90579ff2b4097409b49b1c4f7c6b98c54758de2b /hlsl
parent37e8c1d7e4ac922dfd94276edf9690efb4ce9aba (diff)
Fixed scanlines, nwn. This took much longer to fix than it should have. :[
Diffstat (limited to 'hlsl')
-rw-r--r--hlsl/deconverge.fx29
-rw-r--r--hlsl/phosphor.fx4
-rw-r--r--hlsl/post.fx21
-rw-r--r--hlsl/prescale.fx9
4 files changed, 32 insertions, 31 deletions
diff --git a/hlsl/deconverge.fx b/hlsl/deconverge.fx
index 2618fdffad9..bb56c56274b 100644
--- a/hlsl/deconverge.fx
+++ b/hlsl/deconverge.fx
@@ -72,6 +72,8 @@ uniform float GrnRadialConvergeY;
uniform float BluRadialConvergeX;
uniform float BluRadialConvergeY;
+uniform float Prescale;
+
VS_OUTPUT vs_main(VS_INPUT Input)
{
VS_OUTPUT Output = (VS_OUTPUT)0;
@@ -115,23 +117,20 @@ float4 ps_main(PS_INPUT Input) : COLOR
Deconverge = 1.0f;//clamp(Deconverge, 0.0f, 1.0f);
float Alpha = tex2D(DiffuseSampler, Input.TexCoord).a;
- float2 RawDims = float2(RawWidth, RawHeight);
- float2 TexCoord = Input.TexCoord * RawDims;
- float2 RedCoord = Input.RedCoord * RawDims;
- float2 GrnCoord = Input.GrnCoord * RawDims;
- float2 BluCoord = Input.BluCoord * RawDims;
- TexCoord.y = TexCoord.y - frac(TexCoord.y);
- RedCoord.y = RedCoord.y - frac(RedCoord.y);
- GrnCoord.y = GrnCoord.y - frac(GrnCoord.y);
- BluCoord.y = BluCoord.y - frac(BluCoord.y);
+ float2 TargetDims = float2(RawWidth * Prescale, RawHeight * Prescale);
+ float2 DimOffset = 0.5f / TargetDims;
+ float2 TexCoord = Input.TexCoord;
+ float2 RedCoord = Input.RedCoord;
+ float2 GrnCoord = Input.GrnCoord;
+ float2 BluCoord = Input.BluCoord;
- RedCoord = lerp(TexCoord, RedCoord, Deconverge) / RawDims;
- GrnCoord = lerp(TexCoord, GrnCoord, Deconverge) / RawDims;
- BluCoord = lerp(TexCoord, BluCoord, Deconverge) / RawDims;
+ RedCoord = lerp(TexCoord, RedCoord, Deconverge);
+ GrnCoord = lerp(TexCoord, GrnCoord, Deconverge);
+ BluCoord = lerp(TexCoord, BluCoord, Deconverge);
- float RedTexel = tex2D(DiffuseSampler, RedCoord + float2(0.0f, 0.5f) / RawDims).r;
- float GrnTexel = tex2D(DiffuseSampler, GrnCoord + float2(0.0f, 0.5f) / RawDims).g;
- float BluTexel = tex2D(DiffuseSampler, BluCoord + float2(0.0f, 0.5f) / RawDims).b;
+ float RedTexel = tex2D(DiffuseSampler, RedCoord - DimOffset).r;
+ float GrnTexel = tex2D(DiffuseSampler, GrnCoord - DimOffset).g;
+ float BluTexel = tex2D(DiffuseSampler, BluCoord - DimOffset).b;
//RedTexel *= Input.RedCoord.x < (WidthRatio / RawWidth) ? 0.0f : 1.0f;
//RedTexel *= Input.RedCoord.y < (HeightRatio / RawHeight) ? 0.0f : 1.0f;
diff --git a/hlsl/phosphor.fx b/hlsl/phosphor.fx
index aba572743ba..5f94828dfc3 100644
--- a/hlsl/phosphor.fx
+++ b/hlsl/phosphor.fx
@@ -79,7 +79,7 @@ VS_OUTPUT vs_main(VS_INPUT Input)
float2 InvTexSize = float2(1.0f / TargetWidth, 1.0f / TargetHeight);
Output.TexCoord = Input.TexCoord + 0.5f * InvTexSize;
- Output.PrevCoord = Input.TexCoord + 0.5f * InvTexSize;
+ Output.PrevCoord = Input.TexCoord;// + 0.5f * InvTexSize;
return Output;
}
@@ -101,7 +101,7 @@ float4 ps_main(PS_INPUT Input) : COLOR
float GreenMax = max(CurrPix.g, PrevPix.g);
float BlueMax = max(CurrPix.b, PrevPix.b);
- return float4(RedMax, GreenMax, BlueMax, CurrPix.a);
+ return CurrPix;//float4(RedMax, GreenMax, BlueMax, CurrPix.a);
}
//-----------------------------------------------------------------------------
diff --git a/hlsl/post.fx b/hlsl/post.fx
index 41e54118d95..b3c793e197f 100644
--- a/hlsl/post.fx
+++ b/hlsl/post.fx
@@ -128,21 +128,18 @@ float4 ps_main(PS_INPUT Input) : COLOR
float2 PinUnitCoord = (Input.TexCoord + PinViewpointOffset) * Ratios * 2.0f - 1.0f;
float PincushionR2 = pow(length(PinUnitCoord), 2.0f) / pow(length(Ratios), 2.0f);
float2 PincushionCurve = PinUnitCoord * PincushionAmount * PincushionR2;
- float2 BaseCoord = Input.TexCoord + float2(0.0f, 0.0f / TargetHeight);
- BaseCoord.y *= TargetHeight;
- BaseCoord.y -= frac(BaseCoord.y);
- BaseCoord.y += 0.5f;
- BaseCoord.y /= TargetHeight;
+ float2 BaseCoord = Input.TexCoord;
+ float2 ScanCoord = BaseCoord - 0.5f / (float2(RawWidth, RawHeight) * Ratios);
+
BaseCoord -= 0.5f / Ratios;
BaseCoord *= 1.0f - PincushionAmount * Ratios * 0.2f; // Warning: Magic constant
BaseCoord += 0.5f / Ratios;
BaseCoord += PincushionCurve;
- float2 CurveViewpointOffset = float2(0.2f, 0.0f);
- float2 CurveUnitCoord = (Input.TexCoord + CurveViewpointOffset) * 2.0f - 1.0f;
- float CurvatureR2 = pow(length(CurveUnitCoord),2.0f) / pow(length(Ratios), 2.0f);
- float2 CurvatureCurve = CurveUnitCoord * CurvatureAmount * CurvatureR2;
- float2 ScreenCurveCoord = Input.TexCoord + CurvatureCurve;
+ ScanCoord -= 0.5f / Ratios;
+ ScanCoord *= 1.0f - PincushionAmount * Ratios * 0.2f; // Warning: Magic constant
+ ScanCoord += 0.5f / Ratios;
+ ScanCoord += PincushionCurve;
float2 CurveClipUnitCoord = Input.TexCoord * Ratios * 2.0f - 1.0f;
float CurvatureClipR2 = pow(length(CurveClipUnitCoord),2.0f) / pow(length(Ratios), 2.0f);
@@ -166,9 +163,9 @@ float4 ps_main(PS_INPUT Input) : COLOR
clip((BaseCoord.y > (1.0f / HeightRatio + 1.0f / RawHeight)) ? -1 : 1);
// -- Scanline Simulation --
- float InnerSine = BaseCoord.y * RawHeight * ScanlineScale;
+ float InnerSine = ScanCoord.y * RawHeight * ScanlineScale;
float ScanBrightMod = sin(InnerSine * PI + ScanlineOffset * RawHeight);
- float3 ScanBrightness = lerp(1.0f, pow(ScanBrightMod * ScanBrightMod, ScanlineHeight) * ScanlineBrightScale + 1.0f, ScanlineAmount);
+ float3 ScanBrightness = lerp(1.0f, (pow(ScanBrightMod * ScanBrightMod, ScanlineHeight) * ScanlineBrightScale + 1.0f) * 0.5f, ScanlineAmount);
float3 Scanned = BaseTexel.rgb * ScanBrightness;
// -- Color Compression (increasing the floor of the signal without affecting the ceiling) --
diff --git a/hlsl/prescale.fx b/hlsl/prescale.fx
index 4ba0495320e..633b0872d48 100644
--- a/hlsl/prescale.fx
+++ b/hlsl/prescale.fx
@@ -59,7 +59,7 @@ VS_OUTPUT vs_main(VS_INPUT Input)
Output.Position.y -= 0.5f;
Output.Position *= float4(2.0f, 2.0f, 1.0f, 1.0f);
- Output.TexCoord = Input.TexCoord + 0.5f / float2(RawWidth, RawHeight);
+ Output.TexCoord = Input.TexCoord;
return Output;
}
@@ -70,7 +70,12 @@ VS_OUTPUT vs_main(VS_INPUT Input)
float4 ps_main(PS_INPUT Input) : COLOR
{
- float4 Center = tex2D(DiffuseSampler, Input.TexCoord);
+ float2 RawDims = float2(RawWidth, RawHeight);
+ float2 TexCoord = Input.TexCoord * RawDims;
+ TexCoord -= frac(float2(0.0f, TexCoord.y));
+ TexCoord /= RawDims;
+
+ float4 Center = tex2D(DiffuseSampler, TexCoord);
return Center;
}