Changeset 2196 for trunk/src/lol/image
 Timestamp:
 Jan 3, 2013, 3:46:21 AM (8 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/src/lol/image/color.h
r2195 r2196 69 69 * Convert linear HSV to linear RGB 70 70 */ 71 static vec3 HSVTo LinearRGB(vec3 src)71 static vec3 HSVToRGB(vec3 src) 72 72 { 73 73 vec3 tmp = abs(fract(vec3(src.x) + vec3(3.f, 2.f, 1.f) / 3.f) * 6.f  vec3(3.f)); … … 75 75 } 76 76 77 static vec4 HSVTo LinearRGB(vec4 src)78 { 79 return vec4(HSVTo LinearRGB(src.rgb), src.a);77 static vec4 HSVToRGB(vec4 src) 78 { 79 return vec4(HSVToRGB(src.rgb), src.a); 80 80 } 81 81 … … 109 109 110 110 /* 111 * Convert linear RGB to CIE XYZ111 * Convert linear RGB [0 1] to CIE XYZ [0 100] 112 112 */ 113 113 static vec3 LinearRGBToCIEXYZ(vec3 src) 114 114 { 115 mat3 m(vec3( 0.4124f, 0.2126f, 0.0193f),116 vec3( 0.3576f, 0.7152f, 0.1192f),117 vec3( 0.1805f, 0.0722f, 0.9505f));115 mat3 m(vec3(41.24f, 21.26f, 1.93f), 116 vec3(35.76f, 71.52f, 11.92f), 117 vec3(18.05f, 7.22f, 95.05f)); 118 118 return m * src; 119 119 } … … 125 125 126 126 /* 127 * Convert CIE XYZ to linear RGB127 * Convert CIE XYZ [0 100] to linear RGB [0 1] 128 128 */ 129 129 static vec3 CIEXYZToLinearRGB(vec3 src) 130 130 { 131 mat3 m(vec3( 3.2406f, 0.9689f, 0.0557f),132 vec3( 1.5372f, 1.8758f, 0.2040f),133 vec3(0. 4986f, 0.0415f, 1.0570f));131 mat3 m(vec3( 0.032406f, 0.009689f, 0.000557f), 132 vec3(0.015372f, 0.018758f, 0.002040f), 133 vec3(0.004986f, 0.000415f, 0.010570f)); 134 134 return m * src; 135 135 } … … 156 156 /* 157 157 * Convert CIE XYZ to CIE L*a*b* 158 * Note: XYZ values are normalised using a D65 illuminant. 159 */ 160 static vec3 CIEXYZToCIELab(vec3 src) 158 * Note: XYZ values are normalised using a D65 illuminant if 159 * no white value is provided. 160 */ 161 static vec3 CIEXYZToCIELab(vec3 src, vec3 white) 161 162 { 162 163 float const a = (6.0 * 6.0 * 6.0) / (29 * 29 * 29); … … 165 166 float const d = 1.0 / 3; 166 167 167 /* Normalise XYZ using D65 illuminant */ 168 src *= vec3(1.f / 95.047f, 1.f / 100.f, 1.f / 108.883f); 168 src /= white; 169 169 170 170 vec3 f = b * src + vec3(c); … … 181 181 } 182 182 183 static vec3 CIEXYZToCIELab(vec3 src) 184 { 185 return CIEXYZToCIELab(src, vec3(95.047f, 100.f, 108.883f)); 186 } 187 188 static vec4 CIEXYZToCIELab(vec4 src, vec4 white) 189 { 190 return vec4(CIEXYZToCIELab(src.rgb, white.rgb), src.a); 191 } 192 183 193 static vec4 CIEXYZToCIELab(vec4 src) 184 194 { 185 return vec4(CIEXYZTo LinearRGB(src.rgb), src.a);195 return vec4(CIEXYZToCIELab(src.rgb), src.a); 186 196 } 187 197
Note: See TracChangeset
for help on using the changeset viewer.