From fee2d8eaa790fefaf80e77d072938794b50d13ae Mon Sep 17 00:00:00 2001 From: papadanku <115061077+papadanku@users.noreply.github.com> Date: Mon, 8 Jul 2024 12:26:51 -0700 Subject: [PATCH] cAutoExposure: Use antialiased circles for debug options --- shaders/cAutoExposure.fx | 10 ++++++---- shaders/shared/cProcedural.fxh | 6 ++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/shaders/cAutoExposure.fx b/shaders/cAutoExposure.fx index 1b9dcb3..8a6c1ba 100644 --- a/shaders/cAutoExposure.fx +++ b/shaders/cAutoExposure.fx @@ -9,6 +9,8 @@ #define INCLUDE_CTONEMAP_OUTPUT #include "shared/cTonemap.fxh" +#include "shared/cProcedural.fxh" + /* Automatic exposure shader using hardware blending */ @@ -121,13 +123,13 @@ float3 PS_Exposure(VS2PS_Quad Input) : SV_TARGET0 // Create the needed mask, output 1 if the texcood is within square range float Factor = 1.0 * _Scale; - bool SquareMask = all(abs(SpotMeterPos) <= Factor); - bool DotMask = all(abs(SpotMeterPos) <= (Factor * 0.1)); + float SquareMask = all(abs(SpotMeterPos) <= Factor); + float DotMask = GetAntiAliasShape(length(SpotMeterPos), Factor * 0.1); // Apply square mask to output Output = lerp(Output, NonExposedColor.rgb, SquareMask); // Apply dot mask to output - Output = lerp(Output, 1.0, DotMask); + Output = lerp(1.0, Output, DotMask); } if (_DisplayAverageLuma) @@ -142,7 +144,7 @@ float3 PS_Exposure(VS2PS_Quad Input) : SV_TARGET0 #endif // This mask returns 1 if the texcoord's position is >= 0.1 - float Mask = 1.0 - saturate(dot(abs(DebugAverageLumaTex) >= 0.05, 1.0)); + float Mask = 1.0 - GetAntiAliasShape(length(DebugAverageLumaTex), 0.05); Output = lerp(Output, exp(Luma), Mask); } diff --git a/shaders/shared/cProcedural.fxh b/shaders/shared/cProcedural.fxh index 687fa3e..9e7ef47 100644 --- a/shaders/shared/cProcedural.fxh +++ b/shaders/shared/cProcedural.fxh @@ -121,4 +121,10 @@ return saturate((Noise * 0.5) + 0.5); } + float GetAntiAliasShape(float Distance, float Radius) + { + float AA = fwidth(Distance); + return smoothstep(Radius - AA, Radius, Distance); + } + #endif