glsl-luma
v1.0.1
Published
Get the luma (brightness) of an RGB color in GLSL. Useful for converting images to greyscale
Downloads
230
Maintainers
Readme
glsl-luma
Get the luma (brightness) of an RGB color in GLSL. Useful for converting images to greyscale.
Usage
float value = luma(vec3 rgb)
float value = luma(vec4 rgba)
Takes a vec3
or vec4
color as input, returning the luma as a float
.
precision mediump float;
uniform sampler2D uTexture;
varying vec2 vUv;
#pragma glslify: luma = require(glsl-luma)
void main() {
vec4 color = texture2D(uTexture, vUv);
float brightness = luma(color);
gl_FragColor = vec4(vec3(brightness), 1.0);
}
License
MIT. See LICENSE.md for details.