summaryrefslogtreecommitdiffstatshomepage
path: root/hlsl/color.fx
diff options
context:
space:
mode:
authorGravatarGravatar Ryan Holtz <rholtz@batcountryentertainment.com>2011-05-18 02:17:31 +0000
committerGravatarGravatar Ryan Holtz <rholtz@batcountryentertainment.com>2011-05-18 02:17:31 +0000
commitdf5254338f7c8b4692d8a72afb04bf1287136fac (patch)
tree3850990020eb918573521174b057602aa75faa62 /hlsl/color.fx
parent88058967383b5d23b94c7adeb8bed26ff51a33c3 (diff)
Fixed chroma subsampling in color_heavy.fx and color.fx, nw
Diffstat (limited to 'hlsl/color.fx')
-rw-r--r--hlsl/color.fx29
1 files changed, 14 insertions, 15 deletions
diff --git a/hlsl/color.fx b/hlsl/color.fx
index a94cb5a9eca..f2f3b907a83 100644
--- a/hlsl/color.fx
+++ b/hlsl/color.fx
@@ -129,26 +129,25 @@ uniform float QSubsampleLength = 3.0f;
float4 ps_main(PS_INPUT Input) : COLOR
{
// -- Bandwidth Subsampling --
- float YSubsampleWidth = (RawWidth * 2.0f) / YSubsampleLength;
- float ISubsampleWidth = (RawWidth * 2.0f) / ISubsampleLength;
- float QSubsampleWidth = (RawWidth * 2.0f) / QSubsampleLength;
- float3 SubsampleWidth = float3(YSubsampleWidth, ISubsampleWidth, QSubsampleWidth);
- float3 SubsampleFrac = frac(Input.TexCoord.x * SubsampleWidth);
- float3 SubsampleCoord = (Input.TexCoord.x * SubsampleWidth - SubsampleFrac) / SubsampleWidth + SubsampleFrac / (SubsampleWidth * 2.0f);
-
+ float3 SubsampleWidth = float3(YSubsampleLength, ISubsampleLength, QSubsampleLength);
+ SubsampleWidth = (RawWidth * 2.0f) / SubsampleWidth;
+ float3 SubsampleCoord = Input.TexCoord.x;
+ float3 SubsampleFrac = frac(SubsampleCoord * SubsampleWidth); // Fraction is in subsample width units!
+ SubsampleCoord = (SubsampleCoord * SubsampleWidth - SubsampleFrac) / SubsampleWidth;
+
float4 BaseTexel = tex2D(DiffuseSampler, Input.TexCoord);
float3 YTexel = tex2D(DiffuseSampler, float2(SubsampleCoord.x, Input.TexCoord.y)).rgb;
float3 ITexel = tex2D(DiffuseSampler, float2(SubsampleCoord.y, Input.TexCoord.y)).rgb;
float3 QTexel = tex2D(DiffuseSampler, float2(SubsampleCoord.z, Input.TexCoord.y)).rgb;
- float3 LastYTexel = tex2D(DiffuseSampler, float2(SubsampleCoord.x - SubsampleFrac.x / RawWidth, Input.TexCoord.y)).rgb;
- float3 LastITexel = tex2D(DiffuseSampler, float2(SubsampleCoord.y - SubsampleFrac.y / RawWidth, Input.TexCoord.y)).rgb;
- float3 LastQTexel = tex2D(DiffuseSampler, float2(SubsampleCoord.z - SubsampleFrac.z / RawWidth, Input.TexCoord.y)).rgb;
+ float3 LastYTexel = tex2D(DiffuseSampler, float2(SubsampleCoord.x + YSubsampleLength / (RawWidth * 2.0f), Input.TexCoord.y)).rgb;
+ float3 LastITexel = tex2D(DiffuseSampler, float2(SubsampleCoord.y + ISubsampleLength / (RawWidth * 2.0f), Input.TexCoord.y)).rgb;
+ float3 LastQTexel = tex2D(DiffuseSampler, float2(SubsampleCoord.z + QSubsampleLength / (RawWidth * 2.0f), Input.TexCoord.y)).rgb;
- YTexel = lerp(LastYTexel, YTexel, SubsampleFrac.x);
- ITexel = lerp(LastITexel, ITexel, SubsampleFrac.y);
- QTexel = lerp(LastQTexel, QTexel, SubsampleFrac.z);
+ YTexel = lerp(YTexel, LastYTexel, SubsampleFrac.x);
+ ITexel = lerp(ITexel, LastITexel, SubsampleFrac.y);
+ QTexel = lerp(QTexel, LastQTexel, SubsampleFrac.z);
// -- RGB Tint & Shift --
float ShiftedRedY = dot(YTexel, float3(RedFromRed, RedFromGrn, RedFromBlu));
@@ -199,8 +198,8 @@ float4 ps_main(PS_INPUT Input) : COLOR
// -- Final Pixel --
float4 Output = lerp(Input.Color, float4(OutRGB, BaseTexel.a) * Input.Color, Input.ExtraInfo.x);
-
- return BaseTexel;
+
+ return Output;
}
//-----------------------------------------------------------------------------