summaryrefslogtreecommitdiffstatshomepage
path: root/hlsl/focus.fx
diff options
context:
space:
mode:
author ImJezze <jezze@gmx.net>2015-08-02 17:31:54 +0200
committer ImJezze <jezze@gmx.net>2015-08-02 17:31:54 +0200
commit37f6ff0b653f840010a9b2dd18b5df9e6337aa2c (patch)
treec852c4b4fe4de4c4f46f858a4d8721ce0784c37a /hlsl/focus.fx
parent4bcb0c13f50ddb1cd3fd0341b4bb31d9c3c7fc7a (diff)
Refactoring and Fixes
- removed position offset in post.fx - fixed texture offset caused by 0th level of bloom.fx - fixed texture offset caused by focus.fx - changed Passthrough parameter in phosphor.fx to boolean - simplified defocus pass function and calling it twice - removed CU_PHOSPHOR_IGNORE (Passthrough) uniform, which was only used in phosphor pass function and is now directly set - added CU_TARGET_DIMS (TargetDims) uniform based on the current render target - fixed missing Prescal parameter in downsample pass function - some code cleanup
Diffstat (limited to 'hlsl/focus.fx')
-rw-r--r--hlsl/focus.fx43
1 files changed, 16 insertions, 27 deletions
diff --git a/hlsl/focus.fx b/hlsl/focus.fx
index a7c6c7ae8f2..b71bc0dcdc6 100644
--- a/hlsl/focus.fx
+++ b/hlsl/focus.fx
@@ -40,7 +40,6 @@ struct VS_INPUT
float3 Position : POSITION;
float4 Color : COLOR0;
float2 TexCoord : TEXCOORD0;
- float2 Unused : TEXCOORD1;
};
struct PS_INPUT
@@ -61,12 +60,10 @@ struct PS_INPUT
//-----------------------------------------------------------------------------
uniform float2 ScreenDims;
+uniform float2 TargetDims;
uniform float2 Defocus = float2(0.0f, 0.0f);
-uniform float2 Prescale = float2(8.0f, 8.0f);
-
-float2 Coord0Offset = float2( 0.0f, 0.0f);
float2 Coord1Offset = float2(-0.2f, -0.6f);
float2 Coord2Offset = float2( 0.4f, -0.4f);
float2 Coord3Offset = float2( 0.6f, 0.2f);
@@ -79,28 +76,24 @@ VS_OUTPUT vs_main(VS_INPUT Input)
{
VS_OUTPUT Output = (VS_OUTPUT)0;
- float2 ScreenTexelDims = 1.0f / ScreenDims;
+ float2 TargetTexelDims = 1.0f / TargetDims;
Output.Position = float4(Input.Position.xyz, 1.0f);
Output.Position.xy /= ScreenDims;
- Output.Position.y = 1.0f - Output.Position.y;
- Output.Position.xy -= 0.5f;
- Output.Position.xy *= 2.0f;
-
- // todo: there is an offset which can be noticed at lower prescale in high-resolution
- float2 FocusPrescaleOffset = ScreenTexelDims / Prescale;
+ Output.Position.y = 1.0f - Output.Position.y; // flip y
+ Output.Position.xy -= 0.5f; // center
+ Output.Position.xy *= 2.0f; // zoom
- float2 TexCoord = Input.TexCoord;
- TexCoord += FocusPrescaleOffset;
-
- Output.TexCoord0 = TexCoord + Coord0Offset * ScreenTexelDims * Defocus;
- Output.TexCoord1 = TexCoord + Coord1Offset * ScreenTexelDims * Defocus;
- Output.TexCoord2 = TexCoord + Coord2Offset * ScreenTexelDims * Defocus;
- Output.TexCoord3 = TexCoord + Coord3Offset * ScreenTexelDims * Defocus;
- Output.TexCoord4 = TexCoord + Coord4Offset * ScreenTexelDims * Defocus;
- Output.TexCoord5 = TexCoord + Coord5Offset * ScreenTexelDims * Defocus;
- Output.TexCoord6 = TexCoord + Coord6Offset * ScreenTexelDims * Defocus;
- Output.TexCoord7 = TexCoord + Coord7Offset * ScreenTexelDims * Defocus;
+ float2 TexCoord = Input.TexCoord + 0.5f / TargetDims;
+
+ Output.TexCoord0 = TexCoord;
+ Output.TexCoord1 = TexCoord + Coord1Offset * TargetTexelDims * Defocus;
+ Output.TexCoord2 = TexCoord + Coord2Offset * TargetTexelDims * Defocus;
+ Output.TexCoord3 = TexCoord + Coord3Offset * TargetTexelDims * Defocus;
+ Output.TexCoord4 = TexCoord + Coord4Offset * TargetTexelDims * Defocus;
+ Output.TexCoord5 = TexCoord + Coord5Offset * TargetTexelDims * Defocus;
+ Output.TexCoord6 = TexCoord + Coord6Offset * TargetTexelDims * Defocus;
+ Output.TexCoord7 = TexCoord + Coord7Offset * TargetTexelDims * Defocus;
Output.Color = Input.Color;
@@ -123,13 +116,9 @@ float4 ps_main(PS_INPUT Input) : COLOR
float3 d7 = tex2D(DiffuseSampler, Input.TexCoord7).rgb;
float3 blurred = (d0.rgb + d1 + d2 + d3 + d4 + d5 + d6 + d7) / 8.0f;
-
blurred = lerp(d0.rgb, blurred, 1.0f);
+
return float4(blurred, d0.a);
-
- // float4 texel = tex2D(DiffuseSampler, Input.TexCoord0);
-
- // return float4(texel.rgb, 1.0f);
}
//-----------------------------------------------------------------------------