LYGIA Shader Library

srgb2luma (lygia/color/space/srgb2luma)

Get's the luminosity from sRGB. Based on from Rec601 luma (see https://en.wikipedia.org/wiki/Grayscale)

Use:

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

Check it on Github


#ifndef FNC_SRGB2LUMA
#define FNC_SRGB2LUMA
float srgb2luma(const in vec3 srgb) { return dot(srgb, vec3(0.299, 0.587, 0.114)); }
float srgb2luma(const in vec4 srgb) { return rgb2luma(srgb.rgb); }
#endif

Use:

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

Check it on Github


#ifndef FNC_SRGB2LUMA
#define FNC_SRGB2LUMA
float srgb2luma(float3 srgb) { return dot(srgb, float3(0.299, 0.587, 0.114)); }
float srgb2luma(float4 srgb) { return rgb2luma(srgb.rgb); }
#endif

Check it on Github

fn srgb2luma(srgb : vec3f) -> f32 { return dot(srgb, vec3f(0.299, 0.587, 0.114)); }

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