summaryrefslogtreecommitdiffstatshomepage
path: root/hlsl
diff options
context:
space:
mode:
author Ryan Holtz <rholtz@batcountryentertainment.com>2011-06-11 23:46:24 +0000
committer Ryan Holtz <rholtz@batcountryentertainment.com>2011-06-11 23:46:24 +0000
commit80d66bb1d6dee4f6e0d91ddf415d123b0aace1e2 (patch)
tree257920a2a6ab9e564982ab2e06b83d7f77ec976e /hlsl
parent5d2798215c21b68ac84dee11a6f6c7de53cc0ddc (diff)
HLSL Cleanup, no whatsnew:
- Fixed set_vector functionality and simplified shaders as a result - Fixed HLSL presets, 0 to 3, in increasing level of terribleness - Reduced options footprint from RGB triplets Next plan: Separate INI writing.
Diffstat (limited to 'hlsl')
-rw-r--r--hlsl/color.fx39
-rw-r--r--hlsl/deconverge.fx56
-rw-r--r--hlsl/focus.fx20
-rw-r--r--hlsl/post.fx20
4 files changed, 44 insertions, 91 deletions
diff --git a/hlsl/color.fx b/hlsl/color.fx
index e7ceeb57978..5e62dbd6d9f 100644
--- a/hlsl/color.fx
+++ b/hlsl/color.fx
@@ -76,28 +76,11 @@ VS_OUTPUT vs_main(VS_INPUT Input)
// Post-Processing Pixel Shader
//-----------------------------------------------------------------------------
-uniform float RedFromRed = 1.0f;
-uniform float RedFromGrn = 0.0f;
-uniform float RedFromBlu = 0.0f;
-uniform float GrnFromRed = 0.0f;
-uniform float GrnFromGrn = 1.0f;
-uniform float GrnFromBlu = 0.0f;
-uniform float BluFromRed = 0.0f;
-uniform float BluFromGrn = 0.0f;
-uniform float BluFromBlu = 1.0f;
-
-uniform float RedOffset = 0.0f;
-uniform float GrnOffset = 0.0f;
-uniform float BluOffset = 0.0f;
-
-uniform float RedScale = 1.0f;
-uniform float GrnScale = 1.0f;
-uniform float BluScale = 1.0f;
-
-uniform float RedFloor = 0.0f;
-uniform float GrnFloor = 0.0f;
-uniform float BluFloor = 0.0f;
-
+uniform float3 RedRatios = float3(1.0f, 0.0f, 0.0f);
+uniform float3 GrnRatios = float3(0.0f, 1.0f, 0.0f);
+uniform float3 BluRatios = float3(0.0f, 0.0f, 1.0f);
+uniform float3 Offset = float3(0.0f, 0.0f, 0.0f);
+uniform float3 Scale = float3(1.0f, 1.0f, 1.0f);
uniform float Saturation = 1.0f;
float4 ps_main(PS_INPUT Input) : COLOR
@@ -107,14 +90,12 @@ float4 ps_main(PS_INPUT Input) : COLOR
float3 OutRGB = BaseTexel.rgb;
// -- RGB Tint & Shift --
- float ShiftedRed = dot(OutRGB, float3(RedFromRed, RedFromGrn, RedFromBlu));
- float ShiftedGrn = dot(OutRGB, float3(GrnFromRed, GrnFromGrn, GrnFromBlu));
- float ShiftedBlu = dot(OutRGB, float3(BluFromRed, BluFromGrn, BluFromBlu));
+ float ShiftedRed = dot(OutRGB, RedRatios);
+ float ShiftedGrn = dot(OutRGB, GrnRatios);
+ float ShiftedBlu = dot(OutRGB, BluRatios);
// -- RGB Offset & Scale --
- float3 RGBScale = float3(RedScale, GrnScale, BluScale);
- float3 RGBShift = float3(RedOffset, GrnOffset, BluOffset);
- float3 OutTexel = float3(ShiftedRed, ShiftedGrn, ShiftedBlu) * RGBScale + RGBShift;
+ float3 OutTexel = float3(ShiftedRed, ShiftedGrn, ShiftedBlu) * Scale + Offset;
// -- Saturation --
float3 Gray = float3(0.3f, 0.59f, 0.11f);
@@ -122,7 +103,7 @@ float4 ps_main(PS_INPUT Input) : COLOR
float3 OutChroma = OutTexel - OutLuma;
float3 Saturated = OutLuma + OutChroma * Saturation;
- return float4(OutRGB, BaseTexel.a);
+ return float4(Saturated, BaseTexel.a);
}
//-----------------------------------------------------------------------------
diff --git a/hlsl/deconverge.fx b/hlsl/deconverge.fx
index 38651a060d4..7121fe07b46 100644
--- a/hlsl/deconverge.fx
+++ b/hlsl/deconverge.fx
@@ -23,10 +23,9 @@ struct VS_OUTPUT
{
float4 Position : POSITION;
float4 Color : COLOR0;
- float2 RedCoord : TEXCOORD0;
- float2 GrnCoord : TEXCOORD1;
- float2 BluCoord : TEXCOORD2;
- float2 TexCoord : TEXCOORD3;
+ float3 CoordX : TEXCOORD0;
+ float3 CoordY : TEXCOORD1;
+ float2 TexCoord : TEXCOORD2;
};
struct VS_INPUT
@@ -39,22 +38,17 @@ struct VS_INPUT
struct PS_INPUT
{
float4 Color : COLOR0;
- float2 RedCoord : TEXCOORD0;
- float2 GrnCoord : TEXCOORD1;
- float2 BluCoord : TEXCOORD2;
- float2 TexCoord : TEXCOORD3;
+ float3 CoordX : TEXCOORD0;
+ float3 CoordY : TEXCOORD1;
+ float2 TexCoord : TEXCOORD2;
};
//-----------------------------------------------------------------------------
// Deconvergence Vertex Shader
//-----------------------------------------------------------------------------
-uniform float RedConvergeX;
-uniform float RedConvergeY;
-uniform float GrnConvergeX;
-uniform float GrnConvergeY;
-uniform float BluConvergeX;
-uniform float BluConvergeY;
+uniform float3 ConvergeX = float3(0.0f, 0.0f, 0.0f);
+uniform float3 ConvergeY = float3(0.0f, 0.0f, 0.0f);
uniform float TargetWidth;
uniform float TargetHeight;
@@ -65,12 +59,8 @@ uniform float RawHeight;
uniform float WidthRatio;
uniform float HeightRatio;
-uniform float RedRadialConvergeX;
-uniform float RedRadialConvergeY;
-uniform float GrnRadialConvergeX;
-uniform float GrnRadialConvergeY;
-uniform float BluRadialConvergeX;
-uniform float BluRadialConvergeY;
+uniform float3 RadialConvergeX = float3(0.0f, 0.0f, 0.0f);
+uniform float3 RadialConvergeY = float3(0.0f, 0.0f, 0.0f);
uniform float Prescale;
@@ -91,14 +81,8 @@ VS_OUTPUT vs_main(VS_INPUT Input)
Output.Color = Input.Color;
float2 TexCoord = Input.TexCoord;
- Output.RedCoord.x = ((((TexCoord.x / Ratios.x) - 0.5f)) * (1.0f + RedRadialConvergeX / RawWidth) + 0.5f) * Ratios.x + RedConvergeX * invDims.x;
- Output.GrnCoord.x = ((((TexCoord.x / Ratios.x) - 0.5f)) * (1.0f + GrnRadialConvergeX / RawWidth) + 0.5f) * Ratios.x + GrnConvergeX * invDims.x;
- Output.BluCoord.x = ((((TexCoord.x / Ratios.x) - 0.5f)) * (1.0f + BluRadialConvergeX / RawWidth) + 0.5f) * Ratios.x + BluConvergeX * invDims.x;
-
- Output.RedCoord.y = ((((TexCoord.y / Ratios.y) - 0.5f)) * (1.0f + RedRadialConvergeY / RawHeight) + 0.5f) * Ratios.y + RedConvergeY * invDims.y;
- Output.GrnCoord.y = ((((TexCoord.y / Ratios.y) - 0.5f)) * (1.0f + GrnRadialConvergeY / RawHeight) + 0.5f) * Ratios.y + GrnConvergeY * invDims.y;
- Output.BluCoord.y = ((((TexCoord.y / Ratios.y) - 0.5f)) * (1.0f + BluRadialConvergeY / RawHeight) + 0.5f) * Ratios.y + BluConvergeY * invDims.y;
-
+ Output.CoordX = ((((TexCoord.x / Ratios.x) - 0.5f)) * (1.0f + RadialConvergeX / RawWidth) + 0.5f) * Ratios.x + ConvergeX * invDims.x;
+ Output.CoordY = ((((TexCoord.y / Ratios.y) - 0.5f)) * (1.0f + RadialConvergeY / RawHeight) + 0.5f) * Ratios.y + ConvergeY * invDims.y;
Output.TexCoord = TexCoord;
return Output;
@@ -120,17 +104,15 @@ float4 ps_main(PS_INPUT Input) : COLOR
float2 TargetDims = float2(RawWidth, RawHeight);
float2 DimOffset = 0.0f / TargetDims;
float2 TexCoord = Input.TexCoord;
- float2 RedCoord = Input.RedCoord;
- float2 GrnCoord = Input.GrnCoord;
- float2 BluCoord = Input.BluCoord;
+ float3 CoordX = Input.CoordX;
+ float3 CoordY = Input.CoordY;
- RedCoord = lerp(TexCoord, RedCoord, Deconverge);
- GrnCoord = lerp(TexCoord, GrnCoord, Deconverge);
- BluCoord = lerp(TexCoord, BluCoord, Deconverge);
+ CoordX = lerp(TexCoord.x, CoordX, Deconverge);
+ CoordY = lerp(TexCoord.y, CoordY, Deconverge);
- float RedTexel = tex2D(DiffuseSampler, RedCoord - DimOffset).r;
- float GrnTexel = tex2D(DiffuseSampler, GrnCoord - DimOffset).g;
- float BluTexel = tex2D(DiffuseSampler, BluCoord - DimOffset).b;
+ float RedTexel = tex2D(DiffuseSampler, float2(CoordX.x, CoordY.x) - DimOffset).r;
+ float GrnTexel = tex2D(DiffuseSampler, float2(CoordX.y, CoordY.y) - DimOffset).g;
+ float BluTexel = tex2D(DiffuseSampler, float2(CoordX.z, CoordY.z) - 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/focus.fx b/hlsl/focus.fx
index c5e95baf6e8..de660af7d24 100644
--- a/hlsl/focus.fx
+++ b/hlsl/focus.fx
@@ -63,8 +63,7 @@ uniform float TargetHeight;
uniform float WidthRatio;
uniform float HeightRatio;
-uniform float DefocusX;
-uniform float DefocusY;
+uniform float2 Defocus = float2(0.0f, 0.0f);
uniform float FocusEnable;
float2 Coord0Offset = float2( 0.0f, 0.0f);
@@ -92,15 +91,14 @@ VS_OUTPUT vs_main(VS_INPUT Input)
float2 InvTexSize = float2(1.0f / TargetWidth, 1.0f / TargetHeight);
float2 TexCoord = Input.TexCoord;
TexCoord = TexCoord + 0.5f * InvTexSize;
- float2 DefocusVal = float2(DefocusX, DefocusY);
- Output.TexCoord0 = TexCoord + Coord0Offset * InvTexSize * DefocusVal;
- Output.TexCoord1 = TexCoord + Coord1Offset * InvTexSize * DefocusVal;
- Output.TexCoord2 = TexCoord + Coord2Offset * InvTexSize * DefocusVal;
- Output.TexCoord3 = TexCoord + Coord3Offset * InvTexSize * DefocusVal;
- Output.TexCoord4 = TexCoord + Coord4Offset * InvTexSize * DefocusVal;
- Output.TexCoord5 = TexCoord + Coord5Offset * InvTexSize * DefocusVal;
- Output.TexCoord6 = TexCoord + Coord6Offset * InvTexSize * DefocusVal;
- Output.TexCoord7 = TexCoord + Coord7Offset * InvTexSize * DefocusVal;
+ Output.TexCoord0 = TexCoord + Coord0Offset * InvTexSize * Defocus;
+ Output.TexCoord1 = TexCoord + Coord1Offset * InvTexSize * Defocus;
+ Output.TexCoord2 = TexCoord + Coord2Offset * InvTexSize * Defocus;
+ Output.TexCoord3 = TexCoord + Coord3Offset * InvTexSize * Defocus;
+ Output.TexCoord4 = TexCoord + Coord4Offset * InvTexSize * Defocus;
+ Output.TexCoord5 = TexCoord + Coord5Offset * InvTexSize * Defocus;
+ Output.TexCoord6 = TexCoord + Coord6Offset * InvTexSize * Defocus;
+ Output.TexCoord7 = TexCoord + Coord7Offset * InvTexSize * Defocus;
return Output;
}
diff --git a/hlsl/post.fx b/hlsl/post.fx
index eee6aaa4798..94c039219e6 100644
--- a/hlsl/post.fx
+++ b/hlsl/post.fx
@@ -112,16 +112,8 @@ uniform float ShadowV = 0.375f;
uniform float ShadowWidth = 8.0f;
uniform float ShadowHeight = 8.0f;
-uniform float RedFloor = 0.0f;
-uniform float GrnFloor = 0.0f;
-uniform float BluFloor = 0.0f;
-
-uniform float SnapX = 0.0f;
-uniform float SnapY = 0.0f;
-
-uniform float RedPower = 2.2f;
-uniform float GrnPower = 2.2f;
-uniform float BluPower = 2.2f;
+uniform float3 Power = float3(1.0f, 1.0f, 1.0f);
+uniform float3 Floor = float3(0.0f, 0.0f, 0.0f);
float4 ps_main(PS_INPUT Input) : COLOR
{
@@ -173,7 +165,7 @@ float4 ps_main(PS_INPUT Input) : COLOR
float3 Scanned = BaseTexel.rgb * ScanBrightness;
// -- Color Compression (increasing the floor of the signal without affecting the ceiling) --
- Scanned = float3(RedFloor + (1.0f - RedFloor) * Scanned.r, GrnFloor + (1.0f - GrnFloor) * Scanned.g, BluFloor + (1.0f - BluFloor) * Scanned.b);
+ Scanned = Floor + (1.0f - Floor) * Scanned;
float2 ShadowDims = float2(ShadowWidth, ShadowHeight);
float2 ShadowUV = float2(ShadowU, ShadowV);
@@ -185,9 +177,9 @@ float4 ps_main(PS_INPUT Input) : COLOR
// -- Final Pixel --
float4 Output = float4(Scanned * lerp(1.0f, ShadowTexel, ShadowBrightness), BaseTexel.a) * Input.Color;
- Output.r = pow(Output.r, RedPower);
- Output.g = pow(Output.g, GrnPower);
- Output.b = pow(Output.b, BluPower);
+ Output.r = pow(Output.r, Power.r);
+ Output.g = pow(Output.g, Power.g);
+ Output.b = pow(Output.b, Power.b);
return Output;
}