From f70ce8158b7d7fbfa6c758a1915c9dea5fea8c06 Mon Sep 17 00:00:00 2001 From: MajorPainTheCactus Date: Fri, 11 Nov 2022 22:41:24 +0000 Subject: [PATCH] Removed gamma guards as they were corrupting the image as you went to the extremes of gamma - this is not what the various standard's do. I will revisit this once I figure out why they are needed and why they are corrupting the image for now they are out. --- hdr/shaders/include/colour_grade.h | 6 ++++-- hdr/shaders/include/gamma_correct.h | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/hdr/shaders/include/colour_grade.h b/hdr/shaders/include/colour_grade.h index eaec5fb..c34417c 100644 --- a/hdr/shaders/include/colour_grade.h +++ b/hdr/shaders/include/colour_grade.h @@ -74,7 +74,8 @@ vec3 WhiteBalance(float temperature, vec3 colour) float r601ToLinear_1(const float channel) { //return (channel >= 0.081f) ? pow((channel + 0.099f) * (1.0f / 1.099f), (1.0f / 0.45f)) : channel * (1.0f / 4.5f); - return (channel >= 0.081f) ? pow((channel + 0.099f) * (1.0f / 1.099f), HCRT_GAMMA_IN) : channel * (1.0f / 4.5f); + //return (channel >= 0.081f) ? pow((channel + 0.099f) * (1.0f / 1.099f), HCRT_GAMMA_IN) : channel * (1.0f / 4.5f); + return pow((channel + 0.099f) * (1.0f / 1.099f), HCRT_GAMMA_IN); } vec3 r601ToLinear(const vec3 colour) @@ -86,7 +87,8 @@ vec3 r601ToLinear(const vec3 colour) float r709ToLinear_1(const float channel) { //return (channel >= 0.081f) ? pow((channel + 0.099f) * (1.0f / 1.099f), (1.0f / 0.45f)) : channel * (1.0f / 4.5f); - return (channel >= 0.081f) ? pow((channel + 0.099f) * (1.0f / 1.099f), HCRT_GAMMA_IN) : channel * (1.0f / 4.5f); + //return (channel >= 0.081f) ? pow((channel + 0.099f) * (1.0f / 1.099f), HCRT_GAMMA_IN) : channel * (1.0f / 4.5f); + return pow((channel + 0.099f) * (1.0f / 1.099f), HCRT_GAMMA_IN); } vec3 r709ToLinear(const vec3 colour) diff --git a/hdr/shaders/include/gamma_correct.h b/hdr/shaders/include/gamma_correct.h index 7a87c65..52fd38c 100644 --- a/hdr/shaders/include/gamma_correct.h +++ b/hdr/shaders/include/gamma_correct.h @@ -14,7 +14,8 @@ const mat3 kXYZ_to_DCIP3 = mat3 ( float LinearTosRGB_1(const float channel) { - return (channel > 0.0031308f) ? (1.055f * pow(channel, 1.0f / HCRT_GAMMA_OUT)) - 0.055f : channel * 12.92f; + //return (channel > 0.0031308f) ? (1.055f * pow(channel, 1.0f / HCRT_GAMMA_OUT)) - 0.055f : channel * 12.92f; + return (1.055f * pow(channel, 1.0f / HCRT_GAMMA_OUT)) - 0.055f; } vec3 LinearTosRGB(const vec3 colour) @@ -24,7 +25,8 @@ vec3 LinearTosRGB(const vec3 colour) float LinearTo709_1(const float channel) { - return (channel >= 0.018f) ? pow(channel * 1.099f, 1.0f / (HCRT_GAMMA_OUT - 0.18f)) - 0.099f : channel * 4.5f; // Gamma: 2.4 - 0.18 = 2.22 + //return (channel >= 0.018f) ? pow(channel * 1.099f, 1.0f / (HCRT_GAMMA_OUT - 0.18f)) - 0.099f : channel * 4.5f; // Gamma: 2.4 - 0.18 = 2.22 + return pow(channel * 1.099f, 1.0f / (HCRT_GAMMA_OUT - 0.18f)) - 0.099f; } vec3 LinearTo709(const vec3 colour)