Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hughsk/glsl-luma
Get the luma (brightness) of an RGB color in GLSL. Useful for converting images to greyscale
https://github.com/hughsk/glsl-luma
Last synced: 12 days ago
JSON representation
Get the luma (brightness) of an RGB color in GLSL. Useful for converting images to greyscale
- Host: GitHub
- URL: https://github.com/hughsk/glsl-luma
- Owner: hughsk
- License: other
- Created: 2014-06-06T23:15:50.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-06-09T19:35:42.000Z (over 10 years ago)
- Last Synced: 2024-10-17T16:39:38.984Z (22 days ago)
- Language: C
- Homepage: http://hughsk.io/glsl-luma
- Size: 866 KB
- Stars: 32
- Watchers: 6
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# glsl-luma [![stable](http://badges.github.io/stability-badges/dist/stable.svg)](http://github.com/badges/stability-badges)
Get the luma (brightness) of an RGB color in GLSL. Useful for converting images to greyscale.
[![glsl-luma](http://imgur.com/7O5SbmC.png)](http://hughsk.io/glsl-luma)
## Usage
[![NPM](https://nodei.co/npm/glsl-luma.png)](https://nodei.co/npm/glsl-luma/)
### `float value = luma(vec3 rgb)`
### `float value = luma(vec4 rgba)`Takes a `vec3` or `vec4` color as input, returning the luma as a `float`.
``` glsl
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](http://github.com/hughsk/glsl-luma/blob/master/LICENSE.md) for details.