lygia
/v1.1.6
/color
/space
/YPbPr2rgb
)pass a color in RGB and get it in YPbPr from http://www.equasys.de/colorconversion.html
Use:
YPbPr2RGB(<vec3|vec4> color)
#ifndef FNC_YPBPR2RGB
#define FNC_YPBPR2RGB
#ifdef YPBPR_SDTV
const mat3 YPbPr2rgb_mat = mat3(
1., 1., 1.,
0., -.344, 1.772,
1.402, -.714, 0.
);
#else
const mat3 YPbPr2rgb_mat = mat3(
1., 1., 1.,
0., -.187, 1.856,
1.575, -.468, 0.
);
#endif
vec3 YPbPr2rgb(in vec3 rgb) {
return YPbPr2rgb_mat * rgb;
}
vec4 YPbPr2rgb(in vec4 rgb) {
return vec4(YPbPr2rgb(rgb.rgb),rgb.a);
}
#endif
Use:
YPbPr2RGB(<float3|float4> color)
#ifndef FNC_YPBPR2RGB
#define FNC_YPBPR2RGB
#ifdef YPBPR_SDTV
const float3x3 YPbPr2rgb_mat = float3x3(
1., 1., 1.,
0., -.344, 1.772,
1.402, -.714, 0.
);
#else
const float3x3 YPbPr2rgb_mat = float3x3(
1., 1., 1.,
0., -.187, 1.856,
1.575, -.468, 0.
);
#endif
float3 YPbPr2rgb(in float3 rgb) {
return mul(YPbPr2rgb_mat, rgb);
}
float4 YPbPr2rgb(in float4 rgb) {
return float4(YPbPr2rgb(rgb.rgb),rgb.a);
}
#endif
// #ifdef YPBPR_SDTV
// const YPbPr2rgb_mat = mat3x3<f32>(
// vec3<f32>(1.0, 1.0, 1.0),
// vec3<f32>(0.0, -0.344, 1.772),
// vec3<f32>(1.402, -0.714, 0.0)
// );
// #else
const YPbPr2rgb_mat = mat3x3<f32>(
vec3<f32>(1.0, 1.0, 1.0),
vec3<f32>(0.0, -0.187, 1.856),
vec3<f32>(1.575, -0.468, 0.0)
);
// #endif
fn YPbPr2rgb(rgb: vec3<f32>) -> vec3<f32> {
return YPbPr2rgb_mat * rgb;
}
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