Browse Source

Fixed the piecewise function in linearToGamma to use <= instead of < when determining whether to use the linear part of the function.

Alex Szpakowski 9 years ago
parent
commit
314a82b126

+ 1 - 1
src/modules/graphics/opengl/wrap_Graphics.lua

@@ -82,7 +82,7 @@ float linearToGammaPrecise(float c) {
 	return c < 0.0031308 ? c * 12.92 : 1.055 * pow(c, 1.0 / 2.4) - 0.055;
 	return c < 0.0031308 ? c * 12.92 : 1.055 * pow(c, 1.0 / 2.4) - 0.055;
 }
 }
 vec3 linearToGammaPrecise(vec3 c) {
 vec3 linearToGammaPrecise(vec3 c) {
-	bvec3 lt = lessThan(c, vec3(0.0031308));
+	bvec3 lt = lessThanEqual(c, vec3(0.0031308));
 	c.r = lt.r ? c.r * 12.92 : 1.055 * pow(c.r, 1.0 / 2.4) - 0.055;
 	c.r = lt.r ? c.r * 12.92 : 1.055 * pow(c.r, 1.0 / 2.4) - 0.055;
 	c.g = lt.g ? c.g * 12.92 : 1.055 * pow(c.g, 1.0 / 2.4) - 0.055;
 	c.g = lt.g ? c.g * 12.92 : 1.055 * pow(c.g, 1.0 / 2.4) - 0.055;
 	c.b = lt.b ? c.b * 12.92 : 1.055 * pow(c.b, 1.0 / 2.4) - 0.055;
 	c.b = lt.b ? c.b * 12.92 : 1.055 * pow(c.b, 1.0 / 2.4) - 0.055;

+ 1 - 1
src/modules/math/MathModule.cpp

@@ -213,7 +213,7 @@ float Math::gammaToLinear(float c) const
  **/
  **/
 float Math::linearToGamma(float c) const
 float Math::linearToGamma(float c) const
 {
 {
-	if (c < 0.0031308f)
+	if (c <= 0.0031308f)
 		return c * 12.92f;
 		return c * 12.92f;
 	else
 	else
 		return 1.055f * powf(c, 1.0f / 2.4f) - 0.055f;
 		return 1.055f * powf(c, 1.0f / 2.4f) - 0.055f;