From e37ed7cff0f40f6aab1c93de94d97ac94e1c28a5 Mon Sep 17 00:00:00 2001 From: MajorPainTheCactus Date: Tue, 25 Oct 2022 22:41:35 +0100 Subject: [PATCH] Fixed gamma in to use the proper rec. 601 transfer function --- hdr/shaders/crt-sony-megatron-sdr.slangp | 1 - hdr/shaders/include/colour_grade.h | 8 +++++--- hdr/shaders/include/parameters.h | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/hdr/shaders/crt-sony-megatron-sdr.slangp b/hdr/shaders/crt-sony-megatron-sdr.slangp index c0fa22c..c0e12ba 100644 --- a/hdr/shaders/crt-sony-megatron-sdr.slangp +++ b/hdr/shaders/crt-sony-megatron-sdr.slangp @@ -2,4 +2,3 @@ hcrt_hdr = "0.000000" -hcrt_gamma_in = "2.000000" diff --git a/hdr/shaders/include/colour_grade.h b/hdr/shaders/include/colour_grade.h index 9aa2c30..eaec5fb 100644 --- a/hdr/shaders/include/colour_grade.h +++ b/hdr/shaders/include/colour_grade.h @@ -73,7 +73,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), (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); } vec3 r601ToLinear(const vec3 colour) @@ -84,7 +85,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), (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); } vec3 r709ToLinear(const vec3 colour) @@ -173,7 +175,7 @@ vec3 ColourGrade(const vec3 colour) const vec3 white_point = WhiteBalance(kTemperatures[colour_system] + HCRT_WHITE_TEMPERATURE, colour); - const vec3 linear = pow(white_point, vec3(HCRT_GAMMA_IN)); + const vec3 linear = r601ToLinear(white_point); //pow(white_point, vec3(HCRT_GAMMA_IN)); const vec3 xyz = linear * kColourGamut[colour_system]; diff --git a/hdr/shaders/include/parameters.h b/hdr/shaders/include/parameters.h index 84e8534..e0c0aa6 100644 --- a/hdr/shaders/include/parameters.h +++ b/hdr/shaders/include/parameters.h @@ -31,7 +31,7 @@ #pragma parameter hcrt_brightness " Brightness" 0.0 -1.0 1.0 0.01 #pragma parameter hcrt_contrast " Contrast" 0.0 -1.0 1.0 0.01 #pragma parameter hcrt_saturation " Saturation" 0.0 -1.0 1.0 0.01 -#pragma parameter hcrt_gamma_in " Gamma" 2.4 1.0 5.0 0.01 +#pragma parameter hcrt_gamma_in " Gamma" 2.22 1.0 5.0 0.01 #pragma parameter hcrt_pin_phase " Pin Phase" 0.00 -0.2 0.2 0.01 #pragma parameter hcrt_pin_amp " Pin Amp" 0.00 -0.2 0.2 0.01 #pragma parameter hcrt_space3 " " 0.0 0.0 0.0001 0.0001