LYGIA Shader Library

brightnessContrast (lygia/color/brightnessContrast)

Modify brightness and contrast

Use:

brightnessContrast(<float|vec3|vec4> color, <float> brightness, <float> amcontrastount)

Check it on Github


#ifndef FNC_BRIGHTNESSCONTRAST
#define FNC_BRIGHTNESSCONTRAST
float brightnessContrast( float v, float b, float c ) { return ( v - 0.5 ) * c + 0.5 + b; }
vec3 brightnessContrast( vec3 v, float b, float c ) { return ( v - 0.5 ) * c + 0.5 + b; }
vec4 brightnessContrast( vec4 v, float b, float c ) { return vec4(( v.rgb - 0.5 ) * c + 0.5 + b, v.a); }
#endif

Use:

brightnessContrast(<float|float3|float4> color, <float> brightness, <float> amcontrastount)

Check it on Github


#ifndef FNC_BRIGHTNESSCONTRAST
#define FNC_BRIGHTNESSCONTRAST
float brightnessContrast( float value, float brightness, float contrast ) {
    return ( value - 0.5 ) * contrast + 0.5 + brightness;
}

float3 brightnessContrast( float3 color, float brightness, float contrast ) {
    return ( color - 0.5 ) * contrast + 0.5 + brightness;
}

float4 brightnessContrast( float4 color, float brightness, float contrast ) {
    return float4(brightnessContrast(color.rgb, brightness, contrast), color.a);
}
#endif

Use:

brightnessContrast(<float|vec3|vec4> color, <float> brightness, <float> amcontrastount)

Check it on Github


#ifndef FNC_BRIGHTNESSCONTRAST
#define FNC_BRIGHTNESSCONTRAST
float brightnessContrast( float v, float b, float c ) { return ( v - 0.5 ) * c + 0.5 + b; }
float3 brightnessContrast( float3 v, float b, float c ) { return ( v - 0.5 ) * c + 0.5 + b; }
float4 brightnessContrast( float4 v, float b, float c ) { return float4(( v.rgb - 0.5 ) * c + 0.5 + b, v.a); }
#endif

Use:

brightnessContrast(<float|vec3|vec4> color, <float> brightness, <float> amcontrastount)

Check it on Github


fn brightnessContrast(v : f32, b : f32, c : f32) -> f32 { return (v - 0.5) * c + 0.5 + b; }

fn brightnessContrast3(v : vec3f, b : f32, c : f32) -> vec3f { return (v - 0.5) * c + 0.5 + b; }

fn brightnessContrast4(v : vec4f, b : f32, c : f32) -> vec4f { return vec4((v.rgb - 0.5) * c + 0.5 + b, v.a); }

Examples

Licenses

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