LYGIA Shader Library

desaturate (lygia/v1.1.6/color/desaturate)

change saturation of a color

Use:

desaturate(<float|vec3|vec4> color, float amount)

Check it on Github


#ifndef FNC_DESATURATE
#define FNC_DESATURATE
vec3 desaturate(in vec3 v, in float a ) {
    return mix(v, vec3(dot(vec3(.3, .59, .11), v)), a);
}

vec4 desaturate(in vec4 v, in float a ) {
    return vec4(desaturate(v.rgb, a), v.a);
}
#endif

Use:

desaturate(<float|float3|float4> color, float amount)

Check it on Github


#ifndef FNC_DESATURATE
#define FNC_DESATURATE
float3 desaturate(in float3 color, in float amount ) {
    float l = dot(float3(.3, .59, .11), color);
    return lerp(color, float3(l, l, l), amount);
}

float4 desaturate(in float4 color, in float amount ) {
    return float4(desaturate(color.rgb, amount), color.a);
}
#endif

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