LYGIA Shader Library

rgb2luma (lygia/v1.1.6/color/space/rgb2luma)

get's the luminosity of a color. From https://github.com/hughsk/glsl-luma/blob/master/index.glsl

Use:

rgb2luma(<vec3|vec4> color)

Check it on Github


#ifndef FNC_RGB2LUMA
#define FNC_RGB2LUMA
float rgb2luma(in vec3 color) {
    return dot(color, vec3(0.299, 0.587, 0.114));
}

float rgb2luma(in vec4 color) {
    return rgb2luma(color.rgb);
}
#endif

Use:

rgb2luma(<float3 float4> color)

Check it on Github


#ifndef FNC_RGB2LUMA
#define FNC_RGB2LUMA
float rgb2luma(in float3 color) {
    return dot(color, float3(0.299, 0.587, 0.114));
}

float rgb2luma(in float4 color) {
    return rgb2luma(color.rgb);
}
#endif

Check it on Github

fn rgb2luma(color : vec3<f32>) -> f32 {
    return dot(color, vec3<f32>(0.299, 0.587, 0.114));
}

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