LYGIA Shader Library

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

Converts from XYZ to xyY space (Y is the luminance)

Use:

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

Check it on Github


#ifndef FNC_XYZ2XYY 
#define FNC_XYZ2XYY
vec3 xyz2xyY(const in vec3 xyz) {
    float Y = xyz.y;
    float f = 1.0 / (xyz.x + xyz.y + xyz.z);
    float x = xyz.x * f;
    float y = xyz.y * f;
    return vec3(x, y, Y);
}
vec4 xyz2xyY(const in vec4 xyz) { return vec4(xyz2xyY(xyz.xyz), xyz.w);}
#endif

Use:

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

Check it on Github


#ifndef FNC_XYZ2XYY 
#define FNC_XYZ2XYY
float3 xyz2xyY(float3 xyz) {
    float Y = xyz.y;
    float f = 1.0 / (xyz.x + xyz.y + xyz.z);
    float x = xyz.x * f;
    float y = xyz.y * f;
    return float3(x, y, Y);
}
float4 xyz2xyY(float4 xyz) { return float4(xyz2xyY(xyz.xyz), xyz.w);}
#endif

Check it on Github

fn xyz2xyY(xyz: vec3f) -> vec3f {
    let Y = xyz.y;
    let f = 1.0 / (xyz.x + xyz.y + xyz.z);
    let x = xyz.x * f;
    let y = xyz.y * f;
    return vec3f(x, y, Y);
}

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