LYGIA Shader Library

luminance (lygia/color/luminance)

Computes the luminance of the specified linear RGB color using the luminance coefficients from Rec. 709.

Use:

luminance(<vec3|vec4> color)

Check it on Github


#ifndef FNC_LUMINANCE
#define FNC_LUMINANCE
float luminance(in vec3 linear) { return dot(linear, vec3(0.21250175, 0.71537574, 0.07212251)); }
float luminance(in vec4 linear) { return luminance( linear.rgb ); }
#endif

Use:

luminance(<float3|float4> color)

Check it on Github


#ifndef FNC_LUMINANCE
#define FNC_LUMINANCE
float luminance(in float3 _linear) { return dot(_linear, float3(0.2126, 0.7152, 0.0722)); }
float luminance(in float4 _linear) { return luminance( _linear.rgb ); }
#endif

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