lygia
/color
/space
/yuv2rgb
)Pass a color in YUB and get RGB color
Use:
yuv2rgb(<vec3|vec4> color)
#ifndef MAT_YUV2RGB
#define MAT_YUV2RGB
#ifdef YUV_SDTV
const mat3 YUV2RGB = mat3(
1.0, 1.0, 1.0,
0.0, -0.39465, 2.03211,
1.13983, -0.58060, 0.0
);
#else
const mat3 YUV2RGB = mat3(
1.0, 1.0, 1.0,
0.0, -0.21482, 2.12798,
1.28033, -0.38059, 0.0
);
#endif
#endif
#ifndef FNC_YUV2RGB
#define FNC_YUV2RGB
vec3 yuv2rgb(const in vec3 yuv) { return YUV2RGB * yuv; }
vec4 yuv2rgb(const in vec4 yuv) { return vec4(yuv2rgb(yuv.rgb), yuv.a); }
#endif
Use:
yuv2rgb(<float3|float4> color)
#ifndef MAT_YUV2RGB
#define MAT_YUV2RGB
#ifdef YUV_SDTV
static const float3x3 YUV2RGB = float3x3(
1.0, 1.0, 1.0,
0.0, -0.39465, 2.03211,
1.13983, -0.58060, 0.0
);
#else
static const float3x3 YUV2RGB = float3x3(
1.0, 1.0, 1.0,
0.0, -0.21482, 2.12798,
1.28033, -0.38059, 0.0
);
#endif
#endif
#ifndef FNC_YUV2RGB
#define FNC_YUV2RGB
float3 yuv2rgb(in float3 yuv) { return mul(YUV2RGB, yuv); }
float4 yuv2rgb(in float4 yuv) { return float4(yuv2rgb(yuv.rgb), yuv.a); }
#endif
Use:
yuv2rgb(<float3|float4> color)
#ifndef MAT_YUV2RGB
#define MAT_YUV2RGB
#ifdef YUV_SDTV
constant matrix<float, 3, 3> YUV2RGB = matrix<float, 3, 3>(
1.0, 1.0, 1.0,
0.0, -0.39465, 2.03211,
1.13983, -0.58060, 0.0
);
#else
constant matrix<float, 3, 3> YUV2RGB = matrix<float, 3, 3>(
1.0, 1.0, 1.0,
0.0, -0.21482, 2.12798,
1.28033, -0.38059, 0.0
);
#endif
#endif
#ifndef FNC_YUV2RGB
#define FNC_YUV2RGB
float3 yuv2rgb( float3 yuv) { return YUV2RGB * yuv; }
float4 yuv2rgb( float4 yuv) { return float4(yuv2rgb(yuv.rgb), yuv.a); }
#endif
// #ifdef YUV_SDTV
// const YUV2RGB = mat3x3<f32>(
// vec3f(1.0, 1.0, 1.0),
// vec3f(0.0, -0.39465, 2.03211),
// vec3f(1.13983, -0.58060, 0.0)
// );
// #else
const YUV2RGB = mat3x3<f32>(
vec3f(1.0, 1.0, 1.0),
vec3f(0.0, -0.21482, 2.12798),
vec3f(1.28033, -0.38059, 0.0)
);
// #endif
fn yuv2rgb(yuv: vec3f) -> vec3f { return YUV2RGB * yuv; }
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.
Sign up for the news letter bellow, joing the LYGIA's channel on Discord or follow the Github repository