LYGIA Shader Library

vibrance (lygia/color/vibrance)

Vibrance is a smart-tool which cleverly increases the intensity of the more muted colors and leaves the already well-saturated colors alone. Prevents skin tones from becoming overly saturated and unnatural. vibrance from https://github.com/CeeJayDK/SweetFX/blob/master/Shaders/Vibrance.fx

Dependencies:

Use:

<vec3|vec4> vibrance(<vec3|vec4> color, <float> v)

Check it on Github



#ifndef FNC_VIBRANCE
#define FNC_VIBRANCE
vec3 vibrance(in vec3 v, in float vi) {
    float max_v = mmax(v);
    float min_v = mmin(v);
    float sat = max_v - min_v;
    float lum = luma(v);
    return mix(vec3(lum), v, 1.0 + (vi * 1.0 - (sign(vi) * sat)));
}

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

Dependencies:

Use:

<float3|float4> vibrance(<float3|float4> color, <float> v)

Check it on Github



#ifndef FNC_VIBRANCE
#define FNC_VIBRANCE

float3 vibrance(in float3 color, in float v) {
    float max_color = mmax(color);
    float min_color = mmin(color);
    float sat = max_color - min_color;
    float lum = luma(color);
    return lerp(float3(lum, lum, lum), color, 1.0 + (v * 1.0 - (sign(v) * sat)));

}

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

Dependencies:

Check it on Github


fn vibrance(color : vec3f, v:f32) -> vec3f {
    let max_color = max(color.r, max(color.g, color.b));
    let min_color = min(color.r, min(color.g, color.b));
    let sat = max_color - min_color;
    return mix(vec3f( luma(color) ), color, 1.0 + (v * 1.0 - (sign(v) * sat)));
}

License

MIT License (MIT) Copyright (c) 2014 CeeJayDK

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