lygia
/v1.1.6
/color
/space
/gamma2linear
)convert from gamma to linear color space.
Use:
gamma2linear(<float|vec3|vec4> color)
#if !defined(GAMMA) && !defined(TARGET_MOBILE) && !defined(PLATFORM_RPI) && !defined(PLATFORM_WEBGL)
#define GAMMA 2.2
#endif
#ifndef FNC_GAMMA2LINEAR
#define FNC_GAMMA2LINEAR
float gamma2linear(in float v) {
#ifdef GAMMA
return pow(v, GAMMA);
#else
// assume gamma 2.0
return v * v;
#endif
}
vec3 gamma2linear(in vec3 v) {
#ifdef GAMMA
return pow(v, vec3(GAMMA));
#else
// assume gamma 2.0
return v * v;
#endif
}
vec4 gamma2linear(in vec4 v) {
return vec4(gamma2linear(v.rgb), v.a);
}
#endif
Use:
gamma2linear(<float|float3|float4> color)
#if !defined(GAMMA) && !defined(TARGET_MOBILE) && !defined(PLATFORM_RPI) && !defined(PLATFORM_WEBGL)
#define GAMMA 2.2
#endif
#ifndef FNC_GAMMA2LINEAR
#define FNC_GAMMA2LINEAR
float gamma2linear(in float v) {
#ifdef GAMMA
return pow(v, GAMMA);
#else
// assume gamma 2.0
return v * v;
#endif
}
float3 gamma2linear(in float3 v) {
#ifdef GAMMA
return pow(v, float3(GAMMA, GAMMA, GAMMA));
#else
// assume gamma 2.0
return v * v;
#endif
}
float4 gamma2linear(in float4 v) {
return float4(gamma2linear(v.rgb), v.a);
}
#endif
fn gamma2linear(gamma: vec3<f32>) -> vec3<f32> {
return pow(gamma, vec3(2.2));
}
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