lygia
/v1.1.6
/color
/space
/rgb2YCbCr
)convert RGB to YCbCr according to https://en.wikipedia.org/wiki/YCbCr
Use:
rgb2YCbCr(<vec3|vec4> color)
#ifndef FNC_RGB2YCBCR
#define FNC_RGB2YCBCR
vec3 rgb2YCbCr(in vec3 rgb){
float y = dot(rgb, vec3(.299, .587, .114));
float cb = .5 + dot(rgb, vec3(-.168736, -.331264, .5));
float cr = .5 + dot(rgb, vec3(.5, -.418688, -.081312));
return vec3(y, cb, cr);
}
vec4 rgb2YCbCr(in vec4 rgb) {
return vec4(rgb2YCbCr(rgb.rgb),rgb.a);
}
#endif
Use:
rgb2YCbCr(<float3|float4> color)
#ifndef FNC_RGB2YCBCR
#define FNC_RGB2YCBCR
float3 rgb2YCbCr(in float3 rgb){
float y = dot(rgb, float3(.299, .587, .114));
float cb = .5 + dot(rgb, float3(-.168736, -.331264, .5));
float cr = .5 + dot(rgb, float3(.5, -.418688, -.081312));
return float3(y, cb, cr);
}
float4 rgb2YCbCr(in float4 rgb) {
return float4(rgb2YCbCr(rgb.rgb),rgb.a);
}
#endif
fn rgb2YCbCr(rgb: vec3<f32>) -> vec3<f32> {
let y = dot(rgb, vec3<f32>(0.299, 0.587, 0.114));
let cb = 0.5 + dot(rgb, vec3<f32>(-0.168736, -0.331264, 0.5));
let cr = 0.5 + dot(rgb, vec3<f32>(0.5, -0.418688, -0.081312));
return vec3<f32>(y, cb, cr);
}
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