1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| /**
| * Computes the luminance of a color.
| *
| * @name czm_luminance
| * @glslFunction
| *
| * @param {vec3} rgb The color.
| *
| * @returns {float} The luminance.
| *
| * @example
| * float light = czm_luminance(vec3(0.0)); // 0.0
| * float dark = czm_luminance(vec3(1.0)); // ~1.0
| */
| float czm_luminance(vec3 rgb)
| {
| // Algorithm from Chapter 10 of Graphics Shaders.
| const vec3 W = vec3(0.2125, 0.7154, 0.0721);
| return dot(rgb, W);
| }
|
|