Skip to content

Commit

Permalink
fix(shaders): fix gamma correction 2.4 support
Browse files Browse the repository at this point in the history
  • Loading branch information
clshortfuse committed Dec 4, 2024
1 parent 7837e3d commit 2d67a06
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/shaders/colorcorrect.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ namespace correct {
#define GAMMA(T) \
T Gamma(T c, bool pow_to_srgb = false, float gamma = 2.2f) { \
if (pow_to_srgb) { \
return srgb::Decode(gamma::Encode(c, gamma)); \
return srgb::Decode(color::gamma::Encode(c, gamma)); \
} else { \
return gamma::Decode(srgb::Encode(c), gamma); \
return color::gamma::Decode(srgb::Encode(c), gamma); \
} \
}

Expand All @@ -22,15 +22,15 @@ GAMMA(float2)
GAMMA(float3)

float4 Gamma(float4 color, bool pow_to_srgb = false, float gamma = 2.2f) {
return float4(Gamma(color.rgb, gamma), color.a);
return float4(Gamma(color.rgb, pow_to_srgb, gamma), color.a);
}

#define GAMMA_SAFE(T) \
T GammaSafe(T c, bool pow_to_srgb = false, float gamma = 2.2f) { \
if (pow_to_srgb) { \
return renodx::math::Sign(c) * srgb::Decode(gamma::Encode(abs(c), gamma)); \
} else { \
return renodx::math::Sign(c) * gamma::Decode(srgb::Encode(abs(c)), gamma); \
#define GAMMA_SAFE(T) \
T GammaSafe(T c, bool pow_to_srgb = false, float gamma = 2.2f) { \
if (pow_to_srgb) { \
return renodx::math::Sign(c) * srgb::Decode(color::gamma::Encode(abs(c), gamma)); \
} else { \
return renodx::math::Sign(c) * color::gamma::Decode(srgb::Encode(abs(c)), gamma); \
} \
}

Expand All @@ -39,7 +39,7 @@ GAMMA_SAFE(float2)
GAMMA_SAFE(float3)

float4 GammaSafe(float4 color, bool pow_to_srgb = false, float gamma = 2.2f) {
return float4(Gamma(color.rgb, gamma), color.a);
return float4(Gamma(color.rgb, pow_to_srgb, gamma), color.a);
}

#undef GAMMA
Expand Down

0 comments on commit 2d67a06

Please sign in to comment.