LYGIA Shader Library

yiq2rgb (lygia/color/space/yiq2rgb)

Convert a color in YIQ to linear RGB color. From https://en.wikipedia.org/wiki/YIQ

Use:

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

Check it on Github


#ifndef MAT_YIQ2RGB
#define MAT_YIQ2RGB
const mat3 YIQ2RGB = mat3(  1.0,  0.9469,  0.6235, 
                            1.0, -0.2747, -0.6357, 
                            1.0, -1.1085,  1.7020 );
#endif

#ifndef FNC_YIQ2RGB
#define FNC_YIQ2RGB
vec3 yiq2rgb(const in vec3 yiq) { return YIQ2RGB * yiq; }
vec4 yiq2rgb(const in vec4 yiq) { return vec4(yiq2rgb(yiq.rgb), yiq.a); }
#endif

Use:

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

Check it on Github


#ifndef MAT_YIQ2RGB
#define MAT_YIQ2RGB
const float3x3 YIQ2RGB = float3x3(  1.0,  0.9469,  0.6235, 
                                    1.0, -0.2747, -0.6357, 
                                    1.0, -1.1085,  1.7020 );
#endif

#ifndef FNC_YIQ2RGB
#define FNC_YIQ2RGB
float3 yiq2rgb(in float3 yiq) { return mul(yiq2rgb_mat, yiq); }
float4 yiq2rgb(in float4 yiq) { return float4(yiq2rgb(yiq.rgb), yiq.a); }
#endif

Check it on Github

const YIQ2RGB : mat3x3<f32>  = mat3x3<f32>( 
    vec3f(1.0,  0.9469,  0.6235), 
    vec3f(1.0, -0.2747, -0.6357), 
    vec3f(1.0, -1.1085,  1.7020) );
fn yiq2rgb(yiq : vec3f) -> vec3f { return YIQ2RGB * yiq; }

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