Skip to content

Commit

Permalink
cAutoExposure: Use antialiased circles for debug options
Browse files Browse the repository at this point in the history
  • Loading branch information
papadanku committed Jul 8, 2024
1 parent 3133cec commit fee2d8e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
10 changes: 6 additions & 4 deletions shaders/cAutoExposure.fx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#define INCLUDE_CTONEMAP_OUTPUT
#include "shared/cTonemap.fxh"

#include "shared/cProcedural.fxh"

/*
Automatic exposure shader using hardware blending
*/
Expand Down Expand Up @@ -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)
Expand All @@ -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);
}

Expand Down
6 changes: 6 additions & 0 deletions shaders/shared/cProcedural.fxh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit fee2d8e

Please sign in to comment.