summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsTools
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2020-11-29 18:56:53 +0000
committerassiduous <assiduous@diligentgraphics.com>2020-11-29 18:56:53 +0000
commit80e44f29d72cdbcacc991b95ed40dc4e57b3b945 (patch)
tree726417b01a1eac70b38c7db3da5b671b6bad5208 /Graphics/GraphicsTools
parentMinor update to SRGBAverage helper function (diff)
downloadDiligentCore-80e44f29d72cdbcacc991b95ed40dc4e57b3b945.tar.gz
DiligentCore-80e44f29d72cdbcacc991b95ed40dc4e57b3b945.zip
Another minor update to SRGBAverage
Diffstat (limited to 'Graphics/GraphicsTools')
-rw-r--r--Graphics/GraphicsTools/src/GraphicsUtilities.cpp3
1 files changed, 2 insertions, 1 deletions
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<ChannelType>(fSRGBAverage);