Changeset 2188 for trunk/src/lol/image/color.h
 Timestamp:
 Dec 31, 2012, 6:05:21 AM (9 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/src/lol/image/color.h
r2187 r2188 31 31 static vec3 LinearRGBTosRGB(vec3 c) 32 32 { 33 using std::pow; 34 vec3 ret = 12.92 * c; 35 if (c.r > 0.0031308) 36 ret.r = 1.055 * pow(c.r, 1.0 / 2.4)  0.055; 37 if (c.g > 0.0031308) 38 ret.g = 1.055 * pow(c.g, 1.0 / 2.4)  0.055; 39 if (c.b > 0.0031308) 40 ret.b = 1.055 * pow(c.b, 1.0 / 2.4)  0.055; 33 vec3 ret = 12.92f * c; 34 if (c.r > 0.0031308f) 35 ret.r = 1.055f * pow(c.r, 1.0f / 2.4f)  0.055f; 36 if (c.g > 0.0031308f) 37 ret.g = 1.055f * pow(c.g, 1.0f / 2.4f)  0.055f; 38 if (c.b > 0.0031308f) 39 ret.b = 1.055f * pow(c.b, 1.0f / 2.4f)  0.055f; 41 40 return ret; 42 41 } … … 52 51 static vec3 sRGBToLinearRGB(vec3 c) 53 52 { 54 using std::pow; 55 vec3 ret = 1.0 / 12.92 * c; 56 if (c.r > 0.04045) 57 ret.r = pow(c.r + 0.055, 2.4) / pow(1.055, 2.4); 58 if (c.g > 0.04045) 59 ret.g = pow(c.g + 0.055, 2.4) / pow(1.055, 2.4); 60 if (c.b > 0.04045) 61 ret.b = pow(c.b + 0.055, 2.4) / pow(1.055, 2.4); 53 vec3 ret = 1.0f / 12.92f * c; 54 if (c.r > 0.04045f) 55 ret.r = pow(c.r + 0.055f, 2.4f) / pow(1.055f, 2.4f); 56 if (c.g > 0.04045f) 57 ret.g = pow(c.g + 0.055f, 2.4f) / pow(1.055f, 2.4f); 58 if (c.b > 0.04045f) 59 ret.b = pow(c.b + 0.055f, 2.4f) / pow(1.055f, 2.4f); 62 60 return ret; 63 61 } … … 73 71 static vec3 LinearRGBToCIEXYZ(vec3 c) 74 72 { 75 mat3 m(vec3(3.2406 , 0.9689, 0.0557),76 vec3(1.5372 , 1.8758, 0.2040),77 vec3(0.4986 , 0.0415, 1.0570));73 mat3 m(vec3(3.2406f, 0.9689f, 0.0557f), 74 vec3(1.5372f, 1.8758f, 0.2040f), 75 vec3(0.4986f, 0.0415f, 1.0570f)); 78 76 return m * c; 79 77 } … … 89 87 static vec3 CIEXYZToLinearRGB(vec3 c) 90 88 { 91 mat3 m(vec3(0.4124 , 0.2126, 0.0193),92 vec3(0.3576 , 0.7152, 0.1192),93 vec3(0.1805 , 0.0722, 0.9505));89 mat3 m(vec3(0.4124f, 0.2126f, 0.0193f), 90 vec3(0.3576f, 0.7152f, 0.1192f), 91 vec3(0.1805f, 0.0722f, 0.9505f)); 94 92 return m * c; 95 93 }
Note: See TracChangeset
for help on using the changeset viewer.