LYGIA Shader Library

xyY2xyz (lygia/color/space/xyY2xyz)

convert from xyY to XYZ

Use:

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

Check it on Github


#ifndef FNC_XYY2XYZ
#define FNC_XYY2XYZ
vec3 xyY2xyz(const in vec3 xyY) {
    float Y = xyY.z;
    float f = 1.0/xyY.y;
    float x = Y * xyY.x * f;
    float z = Y * (1.0 - xyY.x - xyY.y) * f;
    return vec3(x, Y, z);
}
vec4 xyY2xyz(const in vec4 xyY) { return vec4(xyY2xyz(xyY.xyz), xyY.a); }
#endif

Use:

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

Check it on Github


#ifndef FNC_XYY2XYZ
#define FNC_XYY2XYZ
float3 xyY2xyz(float3 xyY) {
    float Y = xyY.z;
    float f = 1.0/xyY.y;
    float x = Y * xyY.x * f;
    float z = Y * (1.0 - xyY.x - xyY.y) * f;
    return float3(x, Y, z);
}
float4 xyY2xyz(float4 xyY) { return float4(xyY2xyz(xyY.xyz), xyY.w); }
#endif

Check it on Github

fn xyY2xyz(xyY: vec3f) -> vec3f {
    let Y = xyY.z;
    let f = 1.0/xyY.y;
    let x = Y * xyY.x * f;
    let z = Y * (1.0 - xyY.x - xyY.y) * f;
    return vecf(x, Y, z);
}

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