summaryrefslogtreecommitdiffstatshomepage
path: root/hlsl/phosphor.fx
diff options
context:
space:
mode:
author Westley M. Martinez <anikom15@gmail.com>2016-12-16 12:35:58 -0800
committer Westley M. Martinez <anikom15@gmail.com>2016-12-29 14:57:28 -0800
commit0b6f935443d2fa048a9b2f9db8b00cf6cb8e7078 (patch)
tree25f40a0e82b5142c3249aae70fbba1a05bcb00c1 /hlsl/phosphor.fx
parent1fafe7706cbfcfc6e39c23c3c713fbb102557cbe (diff)
Implement new phosphor shader.
hlsl/phosphor.fx: Make changes to the pixel shader. New uniforms: Mode, Tau, Beta, Gamma. Remove Phosphor. Mode selects the mode for phosphor simulation: off (no decay), exponential, inverse power. Tau is the time constant for exp. decay. Beta and Gamma are constants for inv-pow. src/osd/modules/render/d3d/d3dhlsl.cpp: Provide uniforms and add sliders for new options. src/osd/modules/render/d3d/d3dhlsl.h: (BP) Provide new options. src/osd/windows/winmain.cpp: (BP) Provide new options. src/osd/windows/winmain.h: (BP) Provide new options.
Diffstat (limited to 'hlsl/phosphor.fx')
-rw-r--r--hlsl/phosphor.fx38
1 files changed, 29 insertions, 9 deletions
diff --git a/hlsl/phosphor.fx b/hlsl/phosphor.fx
index d78473a2c6e..c6614d09520 100644
--- a/hlsl/phosphor.fx
+++ b/hlsl/phosphor.fx
@@ -93,21 +93,41 @@ 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 int Mode = 0;
+uniform float3 Tau = { 0.0f, 0.0f, 0.0f };
+uniform float3 Beta = { 0.0f, 0.0f, 0.0f };
+uniform float3 Gamma = { 0.0f, 0.0f, 0.0f };
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);
+ float r = PrevPix.r;
+ float g = PrevPix.g;
+ float b = PrevPix.b;
+
+ if (Mode == 0) {
+ r = 0;
+ g = 0;
+ b = 0;
+ }
+ else if (Mode == 1) {
+ r *= exp(-DeltaTime / Tau.r);
+ g *= exp(-DeltaTime / Tau.g);
+ b *= exp(-DeltaTime / Tau.b);
+ }
+ else {
+ if (r != 0.0f)
+ r = pow(Gamma.r * DeltaTime + pow(1 / r, 1 / Beta.r), -Beta.r);
+ if (g != 0.0f)
+ g = pow(Gamma.g * DeltaTime + pow(1 / g, 1 / Beta.g), -Beta.g);
+ if (b != 0.0f)
+ b = pow(Gamma.b * DeltaTime + pow(1 / b, 1 / Beta.b), -Beta.b);
+ }
+ float RedMax = max(CurrPix.r, r);
+ float GreenMax = max(CurrPix.g, g);
+ float BlueMax = max(CurrPix.b, b);
return Passthrough ?
CurrPix : float4(RedMax, GreenMax, BlueMax, CurrPix.a);