Added support for several UNORM_SRGB formats

Signed-off-by: Chris Galvan <chgalvan@amazon.com>
This commit is contained in:
Chris Galvan
2022-02-14 11:10:58 -06:00
parent 49cd9584f2
commit 8cf29ebc25
12 changed files with 56 additions and 152 deletions
+7 -6
View File
@@ -6,6 +6,7 @@
*
*/
#include <AzCore/Math/Color.h>
#include "EditorDefs.h"
@@ -184,9 +185,9 @@ QColor ColorLinearToGamma(ColorF col)
float b = clamp_tpl(col.b, 0.0f, 1.0f);
float a = clamp_tpl(col.a, 0.0f, 1.0f);
r = (float)(r <= 0.0031308 ? (12.92 * r) : (1.055 * pow((double)r, 1.0 / 2.4) - 0.055));
g = (float)(g <= 0.0031308 ? (12.92 * g) : (1.055 * pow((double)g, 1.0 / 2.4) - 0.055));
b = (float)(b <= 0.0031308 ? (12.92 * b) : (1.055 * pow((double)b, 1.0 / 2.4) - 0.055));
r = AZ::Color::ConvertSrgbLinearToGamma(r);
g = AZ::Color::ConvertSrgbLinearToGamma(g);
b = AZ::Color::ConvertSrgbLinearToGamma(b);
return QColor(int(r * 255.0f), int(g * 255.0f), int(b * 255.0f), int(a * 255.0f));
}
@@ -199,9 +200,9 @@ ColorF ColorGammaToLinear(const QColor& col)
float b = (float)col.blue() / 255.0f;
float a = (float)col.alpha() / 255.0f;
return ColorF((float)(r <= 0.04045 ? (r / 12.92) : pow(((double)r + 0.055) / 1.055, 2.4)),
(float)(g <= 0.04045 ? (g / 12.92) : pow(((double)g + 0.055) / 1.055, 2.4)),
(float)(b <= 0.04045 ? (b / 12.92) : pow(((double)b + 0.055) / 1.055, 2.4)), a);
return ColorF(AZ::Color::ConvertSrgbGammaToLinear(r),
AZ::Color::ConvertSrgbGammaToLinear(g),
AZ::Color::ConvertSrgbGammaToLinear(b), a);
}
QColor ColorToQColor(uint32 color)