diff options
Diffstat (limited to 'hlsl')
-rw-r--r-- | hlsl/bloom.fx | 14 | ||||
-rw-r--r-- | hlsl/downsample.fx | 7 | ||||
-rw-r--r-- | hlsl/focus.fx | 43 | ||||
-rw-r--r-- | hlsl/phosphor.fx | 17 | ||||
-rw-r--r-- | hlsl/post.fx | 12 | ||||
-rw-r--r-- | hlsl/primary.fx | 14 |
6 files changed, 50 insertions, 57 deletions
diff --git a/hlsl/bloom.fx b/hlsl/bloom.fx index 9ed97bbd936..e41a663b204 100644 --- a/hlsl/bloom.fx +++ b/hlsl/bloom.fx @@ -186,27 +186,27 @@ uniform float4 Level67Size; uniform float4 Level89Size; uniform float2 LevelASize; -uniform bool PrepareVector = false; - VS_OUTPUT vs_main(VS_INPUT Input) { VS_OUTPUT Output = (VS_OUTPUT)0; 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; + Output.Position.y = 1.0f - Output.Position.y; // flip y + Output.Position.xy -= 0.5f; // center + Output.Position.xy *= 2.0f; // zoom Output.Color = Input.Color; float2 TexCoord = Input.Position.xy / ScreenDims; - Output.TexCoord01 = TexCoord.xyxy + Prescale.xyxy / Level01Size; + + Output.TexCoord01.xy = TexCoord.xy; + Output.TexCoord01.zw = TexCoord.xy + Prescale.xy / Level01Size.zw; Output.TexCoord23 = TexCoord.xyxy + Prescale.xyxy / Level23Size; Output.TexCoord45 = TexCoord.xyxy + Prescale.xyxy / Level45Size; Output.TexCoord67 = TexCoord.xyxy + Prescale.xyxy / Level67Size; Output.TexCoord89 = TexCoord.xyxy + Prescale.xyxy / Level89Size; - Output.TexCoordA = TexCoord.xy + Prescale.xy / LevelASize; + Output.TexCoordA = TexCoord.xy + Prescale.xy / LevelASize; return Output; } diff --git a/hlsl/downsample.fx b/hlsl/downsample.fx index 18eaa8313c0..376e4b8802d 100644 --- a/hlsl/downsample.fx +++ b/hlsl/downsample.fx @@ -60,13 +60,14 @@ VS_OUTPUT vs_main(VS_INPUT Input) 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; + Output.Position.y = 1.0f - Output.Position.y; // flip y + Output.Position.xy -= 0.5f; // center + Output.Position.xy *= 2.0f; // zoom Output.Color = Input.Color; float2 TexCoord = Input.Position.xy / ScreenDims; + Output.TexCoord01.xy = TexCoord + float2(-0.5f, -0.5f) * TargetTexelSize * Prescale; Output.TexCoord01.zw = TexCoord + float2( 0.5f, -0.5f) * TargetTexelSize * Prescale; Output.TexCoord23.xy = TexCoord + float2(-0.5f, 0.5f) * TargetTexelSize * Prescale; 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); } //----------------------------------------------------------------------------- diff --git a/hlsl/phosphor.fx b/hlsl/phosphor.fx index 85647fb83e9..44b00ac0ee7 100644 --- a/hlsl/phosphor.fx +++ b/hlsl/phosphor.fx @@ -47,7 +47,6 @@ struct VS_INPUT float3 Position : POSITION; float4 Color : COLOR0; float2 TexCoord : TEXCOORD0; - float2 Unused : TEXCOORD1; }; struct PS_INPUT @@ -62,10 +61,9 @@ struct PS_INPUT //----------------------------------------------------------------------------- uniform float2 ScreenDims; - uniform float2 TargetDims; -uniform float Passthrough; +uniform bool Passthrough; VS_OUTPUT vs_main(VS_INPUT Input) { @@ -73,13 +71,14 @@ VS_OUTPUT vs_main(VS_INPUT Input) 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 *= float4(2.0f, 2.0f, 1.0f, 1.0f); - Output.Color = Input.Color; + Output.Position.y = 1.0f - Output.Position.y; // flip y + Output.Position.xy -= 0.5f; // center + Output.Position.xy *= 2.0f; // zoom Output.TexCoord = Input.TexCoord + 0.5f / TargetDims; Output.PrevCoord = Output.TexCoord; + + Output.Color = Input.Color; return Output; } @@ -99,7 +98,9 @@ float4 ps_main(PS_INPUT Input) : COLOR float GreenMax = max(CurrPix.g, PrevPix.g); float BlueMax = max(CurrPix.b, PrevPix.b); - return lerp(float4(RedMax, GreenMax, BlueMax, CurrPix.a), CurrPix, Passthrough); + return Passthrough + ? CurrPix + : float4(RedMax, GreenMax, BlueMax, CurrPix.a); } //----------------------------------------------------------------------------- diff --git a/hlsl/post.fx b/hlsl/post.fx index b9a75fd5fa6..57cf821071f 100644 --- a/hlsl/post.fx +++ b/hlsl/post.fx @@ -88,10 +88,6 @@ VS_OUTPUT vs_main(VS_INPUT Input) { VS_OUTPUT Output = (VS_OUTPUT)0; - float4 Position = Input.Position; - Position.xy *= (ScreenDims + 1.0f) / ScreenDims; - Position.xy -= 0.5f / ScreenDims; - float2 shadowUVOffset = ShadowUVOffset; shadowUVOffset = xor(OrientationSwapXY, RotationSwapXY) ? shadowUVOffset.yx @@ -101,16 +97,18 @@ VS_OUTPUT vs_main(VS_INPUT Input) float2 ScreenCoordPrescaleOffset = 0.0f; ScreenCoordPrescaleOffset += shadowUVOffset; - Output.ScreenCoord = Position.xy; + Output.ScreenCoord = Input.Position.xy; Output.ScreenCoord += ScreenCoordPrescaleOffset; - Output.Position = float4(Position.xyz, 1.0f); + Output.Position = float4(Input.Position.xyz, 1.0f); 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.TexCoord = PrepareVector ? (Input.Position.xy / ScreenDims) : Input.TexCoord; + Output.TexCoord = PrepareVector + ? Input.Position.xy / ScreenDims + : Input.TexCoord; // + 0.5f / TargetDims; Output.Color = Input.Color; diff --git a/hlsl/primary.fx b/hlsl/primary.fx index ed73750185d..da9abf028be 100644 --- a/hlsl/primary.fx +++ b/hlsl/primary.fx @@ -33,7 +33,6 @@ struct VS_INPUT float3 Position : POSITION; float4 Color : COLOR0; float2 TexCoord : TEXCOORD0; - float2 Unused : TEXCOORD1; }; struct PS_INPUT @@ -47,6 +46,7 @@ struct PS_INPUT //----------------------------------------------------------------------------- uniform float2 ScreenDims; + uniform bool PostPass; uniform float Brighten; @@ -56,11 +56,13 @@ VS_OUTPUT vs_main(VS_INPUT Input) 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; + Output.Position.y = 1.0f - Output.Position.y; // flip y + Output.Position.xy -= 0.5f; // center + Output.Position.xy *= 2.0f; // zoom - Output.TexCoord = PostPass ? (Input.Position.xy / ScreenDims) : Input.TexCoord; + Output.TexCoord = PostPass + ? Input.Position.xy / ScreenDims + : Input.TexCoord; Output.Color = Input.Color; @@ -87,6 +89,8 @@ technique TestTechnique { Lighting = FALSE; + Sampler[0] = <DiffuseSampler>; + VertexShader = compile vs_2_0 vs_main(); PixelShader = compile ps_2_0 ps_main(); } |