21 lines
442 B
GLSL
21 lines
442 B
GLSL
/**
|
|
* 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);
|
|
}
|