summaryrefslogtreecommitdiffstatshomepage
path: root/hlsl/post.fx
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/post.fx
parent37e8c1d7e4ac922dfd94276edf9690efb4ce9aba (diff)
Fixed scanlines, nwn. This took much longer to fix than it should have. :[
Diffstat (limited to 'hlsl/post.fx')
-rw-r--r--hlsl/post.fx21
1 files changed, 9 insertions, 12 deletions
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) --