Skip to content

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

License

Notifications You must be signed in to change notification settings

hughsk/glsl-luma

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

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

Resources

License

Stars

Watchers

Forks

Packages