glsl-luma

1.0.1 • Public • Published

glsl-luma stable

Get the luma (brightness) of an RGB color in GLSL. Useful for converting images to greyscale.

glsl-luma

Usage

NPM

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.

/glsl-luma/

    Package Sidebar

    Install

    npm i glsl-luma

    Weekly Downloads

    16

    Version

    1.0.1

    License

    MIT

    Last publish

    Collaborators

    • hughsk