summaryrefslogtreecommitdiffstatshomepage
path: root/hlsl/phosphor.fx
diff options
context:
space:
mode:
Diffstat (limited to 'hlsl/phosphor.fx')
-rw-r--r--hlsl/phosphor.fx41
1 files changed, 20 insertions, 21 deletions
diff --git a/hlsl/phosphor.fx b/hlsl/phosphor.fx
index d78473a2c6e..e195f34764d 100644
--- a/hlsl/phosphor.fx
+++ b/hlsl/phosphor.fx
@@ -71,16 +71,16 @@ uniform bool Passthrough;
VS_OUTPUT vs_main(VS_INPUT Input)
{
- VS_OUTPUT Output = (VS_OUTPUT)0;
+ VS_OUTPUT Output = (VS_OUTPUT)0.0;
- Output.Position = float4(Input.Position.xyz, 1.0f);
+ Output.Position = float4(Input.Position.xyz, 1.0);
Output.Position.xy /= ScreenDims;
- Output.Position.y = 1.0f - Output.Position.y; // flip y
- Output.Position.xy -= 0.5f; // center
- Output.Position.xy *= 2.0f; // zoom
+ Output.Position.y = 1.0 - Output.Position.y; // flip y
+ Output.Position.xy -= 0.5; // center
+ Output.Position.xy *= 2.0; // zoom
Output.TexCoord = Input.TexCoord;
- Output.TexCoord += 0.5f / TargetDims; // half texel offset correction (DX9)
+ Output.TexCoord += 0.5 / TargetDims; // half texel offset correction (DX9)
Output.PrevCoord = Output.TexCoord;
@@ -93,24 +93,23 @@ VS_OUTPUT vs_main(VS_INPUT Input)
// Phosphor Pixel Shader
//-----------------------------------------------------------------------------
-uniform float3 Phosphor = float3(0.0f, 0.0f, 0.0f);
-uniform float DeltaTime = 0.0f;
-static const float F = 30.0f;
+uniform float DeltaTime = 0.0;
+uniform float3 Phosphor = float3(0.0, 0.0, 0.0);
+
+static const float F = 30.0;
float4 ps_main(PS_INPUT Input) : COLOR
{
- float4 CurrPix = tex2D(DiffuseSampler, Input.TexCoord);
- float3 PrevPix = tex2D(PreviousSampler, Input.PrevCoord).rgb;
-
- PrevPix.r *= Phosphor.r == 0 ? 0 : pow(Phosphor.r, F * DeltaTime);
- PrevPix.g *= Phosphor.g == 0 ? 0 : pow(Phosphor.g, F * DeltaTime);
- PrevPix.b *= Phosphor.b == 0 ? 0 : pow(Phosphor.b, F * DeltaTime);
- float RedMax = max(CurrPix.r, PrevPix.r);
- float GreenMax = max(CurrPix.g, PrevPix.g);
- float BlueMax = max(CurrPix.b, PrevPix.b);
-
- return Passthrough ?
- CurrPix : float4(RedMax, GreenMax, BlueMax, CurrPix.a);
+ float4 CurrY = tex2D(DiffuseSampler, Input.TexCoord);
+ float3 PrevY = tex2D(PreviousSampler, Input.PrevCoord).rgb;
+
+ PrevY[0] *= Phosphor[0] == 0.0 ? 0.0 : pow(Phosphor[0], F * DeltaTime);
+ PrevY[1] *= Phosphor[1] == 0.0 ? 0.0 : pow(Phosphor[1], F * DeltaTime);
+ PrevY[2] *= Phosphor[2] == 0.0 ? 0.0 : pow(Phosphor[2], F * DeltaTime);
+ float a = max(PrevY[0], CurrY[0]);
+ float b = max(PrevY[1], CurrY[1]);
+ float c = max(PrevY[2], CurrY[2]);
+ return Passthrough ? CurrY : float4(a, b, c, CurrY.a);
}
//-----------------------------------------------------------------------------