lygia
/v1.2.0
/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 MAT_YPBPR2RGB
#define MAT_YPBPR2RGB
#ifdef YPBPR_SDTV
const mat3 YPBPR2RGB = mat3(
1.0, 1.0, 1.0,
0.0, -0.344, 1.772,
1.402, -0.714, 0.0
);
#else
const mat3 YPBPR2RGB = mat3(
1.0, 1.0, 1.0,
0.0, -0.187, 1.856,
1.575, -0.468, 0.0
);
#endif
#endif
#ifndef FNC_YPBPR2RGB
#define FNC_YPBPR2RGB
vec3 YPbPr2rgb(const in vec3 rgb) { return YPBPR2RGB * rgb; }
vec4 YPbPr2rgb(const in vec4 rgb) { return vec4(YPbPr2rgb(rgb.rgb),rgb.a); }
#endif
Use:
YPbPr2RGB(<float3|float4> color)
#ifndef MAT_YPBPR2RGB
#define MAT_YPBPR2RGB
#ifdef YPBPR_SDTV
const float3x3 YPBPR2RGB = float3x3(
1.0, 1.0, 1.0,
0.0, -0.344, 1.772,
1.402, -0.714, 0.0
);
#else
const float3x3 YPBPR2RGB = float3x3(
1.0, 1.0, 1.0,
0.0, -0.187, 1.856,
1.575, -0.468, 0.0
);
#endif
#endif
#ifndef FNC_YPBPR2RGB
#define FNC_YPBPR2RGB
float3 YPbPr2rgb(in float3 rgb) { return mul(YPBPR2RGB, rgb); }
float4 YPbPr2rgb(in float4 rgb) { return float4(YPbPr2rgb(rgb.rgb),rgb.a); }
#endif
// YPBPR_SDTV
// const YPBPR2RGB = mat3x3<f32>(
// vec3f(1.0, 1.0, 1.0),
// vec3f(0.0, -0.344, 1.772),
// vec3f(1.402, -0.714, 0.0)
// );
const YPBPR2RGB = mat3x3<f32>(
vec3f(1.0, 1.0, 1.0),
vec3f(0.0, -0.187, 1.856),
vec3f(1.575, -0.468, 0.0)
);
fn YPbPr2rgb(rgb: vec3f) -> vec3f { return YPBPR2RGB * 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