summaryrefslogtreecommitdiffstatshomepage
path: root/hlsl/phosphor.fx
diff options
context:
space:
mode:
author Westley M. Martinez <anikom15@gmail.com>2018-10-07 08:42:30 -0700
committer R. Belmont <rb6502@users.noreply.github.com>2018-10-07 11:42:30 -0400
commitb5a54b761c94c543ce950dee0bc4aa0610ba8cba (patch)
tree9593e366a3f3da82074dec2b431c3dc8ada08d1c /hlsl/phosphor.fx
parent7b42e2f79950adc1dd6d3c07df5513eda87b507c (diff)
HLSL Color Transforms and 3D LUT (#4043)
* Remove broken scanline uniform from post_pass * Add 3D LUT to HLSL * Allow individual LUTs for screen and UI * WIP: Port 3D LUT to BGFX * Finish porting LUT to BGFX * Add individual phosphor color conversion for HLSL new file: hlsl/chroma.fx Shader for converting xyY3 to sRGB modified: hlsl/phosphor.fx Minor changes to emphasize idea that phosphors are color agnostic modified: hlsl/post.fx Conversion from signal RGB to xyY3 modified: src/osd/modules/render/d3d/d3dhlsl.cpp modified: src/osd/modules/render/d3d/d3dhlsl.h modified: src/osd/windows/winmain.cpp modified: src/osd/windows/winmain.h * Add phosphor examples and update presets * Port phosphor color shaders to BGFX * Fix missing newlines at EOF
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);
}
//-----------------------------------------------------------------------------