1
0
Fork 0
forked from wry/wry

color-management: implement gamma functions for negative values

This commit is contained in:
Julian Orth 2025-09-05 12:34:22 +02:00
parent 050515d2ed
commit 48a36a9feb
2 changed files with 12 additions and 12 deletions

View file

@ -129,9 +129,9 @@ vec3 apply_eotf(vec3 c) {
case TF_SRGB: return eotf_srgb(c);
case TF_LINEAR: return c;
case TF_ST2084_PQ: return eotf_st2084_pq(c);
case TF_GAMMA24: return pow(max(c, 0.0), vec3(2.4));
case TF_GAMMA22: return pow(max(c, 0.0), vec3(2.2));
case TF_GAMMA28: return pow(max(c, 0.0), vec3(2.8));
case TF_GAMMA24: return sign(c) * pow(abs(c), vec3(2.4));
case TF_GAMMA22: return sign(c) * pow(abs(c), vec3(2.2));
case TF_GAMMA28: return sign(c) * pow(abs(c), vec3(2.8));
case TF_ST240: return eotf_st240(c);
case TF_EXT_SRGB: return eotf_ext_srgb(c);
case TF_LOG100: return eotf_log100(c);
@ -146,9 +146,9 @@ vec3 apply_oetf(vec3 c) {
case TF_SRGB: return oetf_srgb(c);
case TF_LINEAR: return c;
case TF_ST2084_PQ: return oetf_st2084_pq(c);
case TF_GAMMA24: return pow(max(c, 0.0), vec3(1.0 / 2.4));
case TF_GAMMA22: return pow(max(c, 0.0), vec3(1.0 / 2.2));
case TF_GAMMA28: return pow(max(c, 0.0), vec3(1.0 / 2.8));
case TF_GAMMA24: return sign(c) * pow(abs(c), vec3(1.0 / 2.4));
case TF_GAMMA22: return sign(c) * pow(abs(c), vec3(1.0 / 2.2));
case TF_GAMMA28: return sign(c) * pow(abs(c), vec3(1.0 / 2.8));
case TF_ST240: return oetf_st240(c);
case TF_EXT_SRGB: return oetf_ext_srgb(c);
case TF_LOG100: return oetf_log100(c);

View file

@ -113,13 +113,13 @@ impl Color {
c.powf(2.6) * 52.37 / 48.0
}
fn gamma22(c: f32) -> f32 {
c.powf(2.2)
c.signum() * c.abs().powf(2.2)
}
fn gamma24(c: f32) -> f32 {
c.powf(2.4)
c.signum() * c.abs().powf(2.4)
}
fn gamma28(c: f32) -> f32 {
c.powf(2.8)
c.signum() * c.abs().powf(2.8)
}
macro_rules! convert {
($tf:ident) => {{
@ -274,13 +274,13 @@ impl Color {
(48.0 * c / 52.37).powf(1.0 / 2.6)
}
fn gamma22(c: f32) -> f32 {
c.powf(1.0 / 2.2)
c.signum() * c.abs().powf(1.0 / 2.2)
}
fn gamma24(c: f32) -> f32 {
c.powf(1.0 / 2.4)
c.signum() * c.abs().powf(1.0 / 2.4)
}
fn gamma28(c: f32) -> f32 {
c.powf(1.0 / 2.8)
c.signum() * c.abs().powf(1.0 / 2.8)
}
macro_rules! convert {
($tf:ident) => {{