lygia
/v1.1.6
/color
/space
/rgb2YPbPr
)pass a color in RGB and get it in YPbPr from http://www.equasys.de/colorconversion.html
Use:
rgb2YPbPr(<vec3|vec4> color)
#ifndef FNC_RGB2YPBPR
#define FNC_RGB2YPBPR
#ifdef YPBPR_SDTV
const mat3 rgb2YPbPr_mat = mat3(
.299, -.169, .5,
.587, -.331, -.419,
.114, .5, -.081
);
#else
const mat3 rgb2YPbPr_mat = mat3(
0.2126, -0.1145721060573399, 0.5,
0.7152, -0.3854278939426601, -0.4541529083058166,
0.0722, 0.5, -0.0458470916941834
);
#endif
vec3 rgb2YPbPr(in vec3 rgb) {
return rgb2YPbPr_mat * rgb;
}
vec4 rgb2YPbPr(in vec4 rgb) {
return vec4(rgb2YPbPr(rgb.rgb),rgb.a);
}
#endif
Use:
rgb2YPbPr(<float3|float4> color)
#ifndef FNC_RGB2YPBPR
#define FNC_RGB2YPBPR
#ifdef YPBPR_SDTV
const float3x3 rgb2YPbPr_mat = float3x3(
.299, -.169, .5,
.587, -.331, -.419,
.114, .5, -.081
);
#else
const float3x3 rgb2YPbPr_mat = float3x3(
0.2126, -0.1145721060573399, 0.5,
0.7152, -0.3854278939426601, -0.4541529083058166,
0.0722, 0.5, -0.0458470916941834
);
#endif
float3 rgb2YPbPr(in float3 rgb) {
return mul(rgb2YPbPr_mat, rgb);
}
float4 rgb2YPbPr(in float4 rgb) {
return float4(rgb2YPbPr(rgb.rgb),rgb.a);
}
#endif
// #ifdef YPBPR_SDTV
// const rgb2YPbPr_mat = mat3x3<f32>(
// vec3<f32>(0.299, -0.169, 0.5),
// vec3<f32>(0.587, -0.331, -0.419),
// vec3<f32>(0.114, 0.5, -0.081)
// );
// #else
const rgb2YPbPr_mat = mat3x3<f32>(
vec3<f32>(0.2126, -0.1145721060573399, 0.5),
vec3<f32>(0.7152, -0.3854278939426601, -0.4541529083058166),
vec3<f32>(0.0722, 0.5, -0.0458470916941834)
);
// #endif
fn rgb2YPbPr(rgb: vec3<f32>) -> vec3<f32> {
return rgb2YPbPr_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