From 80e44f29d72cdbcacc991b95ed40dc4e57b3b945 Mon Sep 17 00:00:00 2001 From: assiduous Date: Sun, 29 Nov 2020 10:56:53 -0800 Subject: Another minor update to SRGBAverage --- Graphics/GraphicsTools/src/GraphicsUtilities.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Graphics/GraphicsTools') diff --git a/Graphics/GraphicsTools/src/GraphicsUtilities.cpp b/Graphics/GraphicsTools/src/GraphicsUtilities.cpp index 93e188fd..664749b2 100644 --- a/Graphics/GraphicsTools/src/GraphicsUtilities.cpp +++ b/Graphics/GraphicsTools/src/GraphicsUtilities.cpp @@ -149,7 +149,8 @@ ChannelType SRGBAverage(ChannelType c0, ChannelType c1, ChannelType c2, ChannelT float fLinearAverage = (FastSRGBToLinear(fc0) + FastSRGBToLinear(fc1) + FastSRGBToLinear(fc2) + FastSRGBToLinear(fc3)) * 0.25f; float fSRGBAverage = FastLinearToSRGB(fLinearAverage) * MaxVal; - // Clamping by MaxVal is essential because fast SRGB math is imprecise + // Clamping on both ends is essential because fast SRGB math is imprecise + fSRGBAverage = std::max(fSRGBAverage, 0.f); fSRGBAverage = std::min(fSRGBAverage, MaxVal); return static_cast(fSRGBAverage); -- cgit v1.2.3