Fix precision issue in CIE/RGB conversions

This commit is contained in:
Vincent Lejeune 2015-01-12 19:41:48 +01:00
parent 1b5ee918f0
commit 3bcdc04279
2 changed files with 2 additions and 2 deletions

View File

@ -9,6 +9,6 @@ vec3 getCIEYxy(vec3 rgbColor)
vec3(.1805, .0722, .9505)));
vec3 xYz = RGB2XYZ * rgbColor;
float tmp = xYz.x + xYz.y + xYz.z;
float tmp = max(xYz.x + xYz.y + xYz.z, 0.1);
return vec3(xYz.y, xYz.xy / tmp);
}

View File

@ -3,7 +3,7 @@
vec3 getRGBFromCIEXxy(vec3 YxyColor)
{
float Yovery = YxyColor.x / YxyColor.z;
float Yovery = YxyColor.x / max(YxyColor.z, 0.1);
vec3 XYZ = vec3(YxyColor.y * Yovery, YxyColor.x, (1. - YxyColor.y - YxyColor.z) * Yovery);
mat3 XYZ2RGB = transpose(mat3(