From ef16086fea92b1cbb767077535bf469b518cb8c0 Mon Sep 17 00:00:00 2001 From: Jezze Date: Sat, 22 Oct 2016 22:39:14 +0200 Subject: Disabled clearing of render targets in several passes (HLSL) - which was quite a performance overhead and not necessary because the shaders fill every texel of a target without blending --- hlsl/distortion.fx | 16 +++++++++------- hlsl/post.fx | 29 ++++++++++++++--------------- 2 files changed, 23 insertions(+), 22 deletions(-) (limited to 'hlsl') diff --git a/hlsl/distortion.fx b/hlsl/distortion.fx index 7624d962a58..3dd1dbd44b6 100644 --- a/hlsl/distortion.fx +++ b/hlsl/distortion.fx @@ -120,6 +120,7 @@ uniform float RoundCornerAmount = 0.0f; uniform float SmoothBorderAmount = 0.0f; uniform float VignettingAmount = 0.0f; uniform float ReflectionAmount = 0.0f; +uniform float3 LightReflectionColor = float3(1.0f, 0.90f, 0.80f); // color temperature 5.000 Kelvin uniform bool SwapXY = false; @@ -280,7 +281,12 @@ float4 ps_main(PS_INPUT Input) : COLOR float2 QuadCoord = GetQuadCoords(Input.TexCoord, BaseTargetQuadScale, distortCornerAmount, 0.0f); // clip border - clip(BaseCoord < 0.0f - TexelDims || BaseCoord > 1.0f + TexelDims ? -1 : 1); + if (BaseCoord.x < 0.0f - TexelDims.x || BaseCoord.y < 0.0f - TexelDims.y || + BaseCoord.x > 1.0f + TexelDims.x || BaseCoord.y > 1.0f + TexelDims.y) + { + // we don't use the clip function, because we don't clear the render target before + return float4(0.0f, 0.0f, 0.0f, 1.0f); + } // Color float4 BaseColor = tex2D(DiffuseSampler, BaseCoord); @@ -293,14 +299,10 @@ float4 ps_main(PS_INPUT Input) : COLOR BaseColor.rgb *= VignetteFactor; // Light Reflection Simulation - float3 LightColor = float3(1.0f, 0.90f, 0.80f); // color temperature 5.000 Kelvin - float2 SpotCoord = QuadCoord; - float2 NoiseCoord = QuadCoord; - float SpotAddend = GetSpotAddend(SpotCoord, ReflectionAmount); - float NoiseFactor = GetNoiseFactor(SpotAddend, random(NoiseCoord)); - BaseColor.rgb += SpotAddend * NoiseFactor * LightColor; + float SpotAddend = GetSpotAddend(SpotCoord, ReflectionAmount) * LightReflectionColor; + BaseColor.rgb += SpotAddend * GetNoiseFactor(SpotAddend, random(SpotCoord)); // Round Corners Simulation float2 RoundCornerCoord = QuadCoord; diff --git a/hlsl/post.fx b/hlsl/post.fx index e6dda5a9474..dcc4ee3b194 100644 --- a/hlsl/post.fx +++ b/hlsl/post.fx @@ -49,17 +49,15 @@ struct VS_OUTPUT { float4 Position : POSITION; float4 Color : COLOR0; - float2 SourceCoord : TEXCOORD0; - float2 TexCoord : TEXCOORD1; - float2 ScreenCoord : TEXCOORD2; + float2 TexCoord : TEXCOORD0; + float2 ScreenCoord : TEXCOORD1; }; struct PS_INPUT { float4 Color : COLOR0; - float2 SourceCoord : TEXCOORD0; - float2 TexCoord : TEXCOORD1; - float2 ScreenCoord : TEXCOORD2; + float2 TexCoord : TEXCOORD0; + float2 ScreenCoord : TEXCOORD1; }; //----------------------------------------------------------------------------- @@ -104,9 +102,6 @@ VS_OUTPUT vs_main(VS_INPUT Input) Output.ScreenCoord = Input.Position.xy / ScreenDims; - Output.SourceCoord = Input.TexCoord; - Output.SourceCoord += 0.5f / TargetDims; // fix half texel offset (DX9) - Output.Color = Input.Color; return Output; @@ -209,19 +204,23 @@ float4 ps_main(PS_INPUT Input) : COLOR { float2 ScreenCoord = Input.ScreenCoord; float2 BaseCoord = GetAdjustedCoords(Input.TexCoord); - float2 SourceCoord = GetAdjustedCoords(Input.SourceCoord); // Color float4 BaseColor = tex2D(DiffuseSampler, BaseCoord); BaseColor.a = 1.0f; // clip border - clip(BaseCoord < 0.0f || BaseCoord > 1.0f ? -1 : 1); + if (BaseCoord.x < 0.0f || BaseCoord.y < 0.0f || + BaseCoord.x > 1.0f || BaseCoord.y > 1.0f) + { + // we don't use the clip function, because we don't clear the render target before + return float4(0.0f, 0.0f, 0.0f, 1.0f); + } // Mask Simulation (may not affect bloom) if (!PrepareBloom && ShadowAlpha > 0.0f) { - float2 ShadowCoord = GetShadowCoord(ScreenCoord, SourceCoord); + float2 ShadowCoord = GetShadowCoord(ScreenCoord, BaseCoord); float4 ShadowColor = tex2D(ShadowSampler, ShadowCoord); float3 ShadowMaskColor = lerp(1.0f, ShadowColor.rgb, ShadowAlpha); @@ -256,7 +255,7 @@ float4 ps_main(PS_INPUT Input) : COLOR float ColorBrightness = 0.299f * BaseColor.r + 0.587f * BaseColor.g + 0.114 * BaseColor.b; - float ScanlineCoord = SourceCoord.y; + float ScanlineCoord = BaseCoord.y; ScanlineCoord += SwapXY ? QuadDims.x <= SourceDims.x * 2.0f ? 0.5f / QuadDims.x // uncenter scanlines if the quad is less than twice the size of the source @@ -280,7 +279,7 @@ float4 ps_main(PS_INPUT Input) : COLOR if (!VectorScreen && HumBarAlpha > 0.0f) { float HumBarStep = frac(TimeMilliseconds * HumBarDesync); - float HumBarBrightness = 1.0 - frac(SourceCoord.y + HumBarStep) * HumBarAlpha; + float HumBarBrightness = 1.0 - frac(BaseCoord.y + HumBarStep) * HumBarAlpha; BaseColor.rgb *= HumBarBrightness; } } @@ -301,4 +300,4 @@ technique DefaultTechnique VertexShader = compile vs_3_0 vs_main(); PixelShader = compile ps_3_0 ps_main(); } -} \ No newline at end of file +} -- cgit v1.2.3-70-g09d2