LYGIA Shader Library

rgb2luma (lygia/color/space/rgb2luma)

Get's the luminosity from linear RGB, based on Rec709 luminance (see https://en.wikipedia.org/wiki/Grayscale)

Use:

<float> rgb2luma(<vec3|vec4> rgb)

Check it on Github


#ifndef FNC_RGB2LUMA
#define FNC_RGB2LUMA
float rgb2luma(const in vec3 rgb) { return dot(rgb, vec3(0.2126, 0.7152, 0.0722)); }
float rgb2luma(const in vec4 rgb) { return rgb2luma(rgb.rgb); }
#endif

Use:

<float> rgb2luma(<float3|float4> rgb)

Check it on Github


#ifndef FNC_RGB2LUMA
#define FNC_RGB2LUMA
float rgb2luma(const in float3 rgb) { return dot(rgb, float3(0.2126, 0.7152, 0.0722)); }
float rgb2luma(const in float4 rgb) { return rgb2luma(rgb.rgb); }
#endif

Check it on Github

fn rgb2luma(rgb: vec3f) -> f32 { return dot(rgb, vec3(0.2126, 0.7152, 0.0722)); }

License

LYGIA is dual-licensed under the Prosperity License and the Patron License for sponsors and contributors.

Sponsors and contributors are automatically added to the Patron License and they can ignore the any non-commercial rule of the Prosperity Licensed software (please take a look to the exception).

It's also possible to get a permanent comercial license hook to a single and specific version of LYGIA.

Get the latest news and releases

Sign up for the news letter bellow, joing the LYGIA's channel on Discord or follow the Github repository