1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
| /**
| * Converts an RGB color to CIE Yxy.
| * <p>The conversion is described in
| * {@link http://content.gpwiki.org/index.php/D3DBook:High-Dynamic_Range_Rendering#Luminance_Transform|Luminance Transform}
| * </p>
| *
| * @name czm_RGBToXYZ
| * @glslFunction
| *
| * @param {vec3} rgb The color in RGB.
| *
| * @returns {vec3} The color in CIE Yxy.
| *
| * @example
| * vec3 xyz = czm_RGBToXYZ(rgb);
| * xyz.x = max(xyz.x - luminanceThreshold, 0.0);
| * rgb = czm_XYZToRGB(xyz);
| */
| vec3 czm_RGBToXYZ(vec3 rgb)
| {
| const mat3 RGB2XYZ = mat3(0.4124, 0.2126, 0.0193,
| 0.3576, 0.7152, 0.1192,
| 0.1805, 0.0722, 0.9505);
| vec3 xyz = RGB2XYZ * rgb;
| vec3 Yxy;
| Yxy.r = xyz.g;
| float temp = dot(vec3(1.0), xyz);
| Yxy.gb = xyz.rg / temp;
| return Yxy;
| }
|
|