LYGIA Shader Library

contrastMatrix (lygia/color/contrastMatrix)

Generate a matrix to change a the contrast of any color

Use:

contrastMatrix(<float> amount)

Check it on Github


#ifndef FNC_CONTRASTMATRIX
#define FNC_CONTRASTMATRIX
mat4 contrastMatrix(in float a) {
    float t = ( 1. - a ) * .5;
    return mat4( a, .0, .0, .0,
                .0, a, .0, .0,
                .0, .0, a, .0,
                t,   t, t, 1. );
}
#endif

Use:

contrastMatrix(<float> amount)

Check it on Github


#ifndef FNC_CONTRASTMATRIX
#define FNC_CONTRASTMATRIX
float4x4 contrastMatrix(in float amount) {
    float t = ( 1. - amount ) * .5;
    return float4x4(  amount, .0, .0, t,
                      .0, amount, .0, t,
                      .0, .0, amount, t,
                      .0, .0,     .0, 1. );
}
#endif

Use:

contrastMatrix(<float> amount)

Check it on Github


#ifndef FNC_CONTRASTMATRIX
#define FNC_CONTRASTMATRIX
mat4 contrastMatrix(float a) {
    float t = ( 1. - a ) * .5;
    return mat4( a, .0, .0, .0,
                .0, a, .0, .0,
                .0, .0, a, .0,
                t,   t, t, 1. );
}
#endif

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