LYGIA Shader Library

hsl2rgb (lygia/color/space/hsl2rgb)

Converts a HSL color to linear RGB

Dependencies:

Use:

<vec3|vec4> hsl2rgb(<vec3|vec4> hsl)

Check it on Github



#ifndef FNC_HSL2RGB
#define FNC_HSL2RGB
vec3 hsl2rgb(const in vec3 hsl) {
    vec3 rgb = hue2rgb(hsl.x);
    float C = (1.0 - abs(2.0 * hsl.z - 1.0)) * hsl.y;
    return (rgb - 0.5) * C + hsl.z;
}
vec4 hsl2rgb(const in vec4 hsl) { return vec4(hsl2rgb(hsl.xyz), hsl.w); }
#endif

Dependencies:

Use:

<float3|float4> hsl2rgb(<float3|float4> hsl)

Check it on Github



#ifndef FNC_HSL2RGB
#define FNC_HSL2RGB
float3 hsl2rgb(const in float3 hsl) {
    float3 rgb = hue2rgb(hsl.x);
    float C = (1.0 - abs(2.0 * hsl.z - 1.0)) * hsl.y;
    return (rgb - 0.5) * C + hsl.z;
}
float4 hsl2rgb(const in float4 hsl) { return float4(hsl2rgb(hsl.xyz), hsl.w); }
#endif

Dependencies:

Use:

<float3|float4> hsl2rgb(<float3|float4> hsl)

Check it on Github



#ifndef FNC_HSL2RGB
#define FNC_HSL2RGB
float3 hsl2rgb( float3 hsl) {
    float3 rgb = hue2rgb(hsl.x);
    float C = (1.0 - abs(2.0 * hsl.z - 1.0)) * hsl.y;
    return (rgb - 0.5) * C + hsl.z;
}
float4 hsl2rgb( float4 hsl) { return float4(hsl2rgb(hsl.xyz), hsl.w); }
#endif

Dependencies:

Check it on Github




fn hsl2rgb(hsl: vec3f) -> vec3f {
    let rgb = hue2rgb(hsl.x);
    let C = (1.0 - abs(2.0 * hsl.z - 1.0)) * hsl.y;
    return (rgb - 0.5) * C + hsl.z;
}

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