LYGIA Shader Library

lab2lch (lygia/v1.2.0/color/space/lab2lch)

Converts a LCh to Lab color space. Note: LCh is simply Lab but converted to polar coordinates (in degrees).

Use:

<vec3|vec4> lab2rgb(<vec3|vec4> color)

Check it on Github


#ifndef FNC_LAB2LCH
#define FNC_LAB2LCH
vec3 lab2lch(vec3 lab) {
    return vec3(
        lab.x,
        sqrt(dot(lab.yz, lab.yz)),
        atan(lab.z, lab.y) * 57.2957795131
    );
}
vec4 lab2lch(vec4 lab) { return vec4(lab2lch(lab.xyz), lab.a); }
#endif

Use:

<float3|float4> lab2rgb(<float3|float4> color)

Check it on Github


#ifndef FNC_LAB2LCH
#define FNC_LAB2LCH
float3 lab2lch(float3 lab) {
    return float3(
        lab.x,
        sqrt(dot(lab.yz, lab.yz)),
        atan(lab.z, lab.y) * 57.2957795131
    );
}
float4 lab2lch(float4 lab) { return float4(lab2lch(lab.xyz), lab.a); }
#endif

Check it on Github

fn lab2lch(lab: vec3f) -> vec3f {
    return vec3f(
        lab.x,
        sqrt(dot(lab.yz, lab.yz)),
        atan(lab.z, lab.y) * 57.2957795131
    );
}

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