From 5be1b777916ee3521f25eef3ea501bc07a7a1bc4 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Fri, 30 Oct 2020 00:15:08 -0500 Subject: [PATCH] get gl side HDR compiling, attempt clamp to keep bloom in range --- .../postFX/scripts/HDR/downScale4x4P.glsl | 2 +- .../postFX/scripts/HDR/finalPassCombineP.glsl | 19 ++++++++----------- .../postFX/scripts/HDR/finalPassCombineP.hlsl | 2 +- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/Templates/BaseGame/game/core/postFX/scripts/HDR/downScale4x4P.glsl b/Templates/BaseGame/game/core/postFX/scripts/HDR/downScale4x4P.glsl index 8ff63a6b2..5945ca60e 100644 --- a/Templates/BaseGame/game/core/postFX/scripts/HDR/downScale4x4P.glsl +++ b/Templates/BaseGame/game/core/postFX/scripts/HDR/downScale4x4P.glsl @@ -22,7 +22,7 @@ #define IN_GLSL #include "core/rendering/shaders/shdrConsts.h" -#include ".core/rendering/shaders/gl/hlslCompat.glsl" +#include "core/rendering/shaders/gl/hlslCompat.glsl" #include "shadergen:/autogenConditioners.h" in vec4 texCoords[8]; diff --git a/Templates/BaseGame/game/core/postFX/scripts/HDR/finalPassCombineP.glsl b/Templates/BaseGame/game/core/postFX/scripts/HDR/finalPassCombineP.glsl index 21956e036..3935cbf43 100644 --- a/Templates/BaseGame/game/core/postFX/scripts/HDR/finalPassCombineP.glsl +++ b/Templates/BaseGame/game/core/postFX/scripts/HDR/finalPassCombineP.glsl @@ -69,28 +69,25 @@ float3 ACESFilm( float3 x ) const float c = 2.43; const float d = 0.59; const float e = 0.14; - return sat((x*(a*x+b))/(x*(c*x+d)+e)); + return saturate((x*(a*x+b))/(x*(c*x+d)+e)); } vec3 tonemap(vec3 c) { vec3 colorOut = c; - + if(g_fTonemapMode == 1.0) { const float W = 11.2; float ExposureBias = 2.0f; - float ExposureAdjust = 1.5f; - c *= ExposureAdjust; - vec3 curr = Uncharted2Tonemap(ExposureBias*c); - vec3 whiteScale = 1.0f / Uncharted2Tonemap(vec3(W,W,W)); - - colorOut = curr*whiteScale; - } + //float ExposureAdjust = 1.5f; + //c *= ExposureAdjust; + colorOut = Uncharted2Tonemap(ExposureBias*colorOut); + colorOut = colorOut * (1.0f / Uncharted2Tonemap(vec3(W,W,W))); } else if(g_fTonemapMode == 2.0) { - colorOut = ACESFilm(c); + colorOut = ACESFilm(colorOut); } return colorOut; @@ -123,7 +120,7 @@ void main() } // Add the bloom effect. - _sample += g_fBloomScale * bloom; + _sample.rgb += clamp(vec3(g_fBloomScale,g_fBloomScale,g_fBloomScale) * bloom.rgb, vec3(0,0,0), vec3(1.0,1.0,1.0)); // Apply contrast _sample.rgb = ((_sample.rgb - 0.5f) * Contrast) + 0.5f; diff --git a/Templates/BaseGame/game/core/postFX/scripts/HDR/finalPassCombineP.hlsl b/Templates/BaseGame/game/core/postFX/scripts/HDR/finalPassCombineP.hlsl index 24bca9779..92a17190d 100644 --- a/Templates/BaseGame/game/core/postFX/scripts/HDR/finalPassCombineP.hlsl +++ b/Templates/BaseGame/game/core/postFX/scripts/HDR/finalPassCombineP.hlsl @@ -113,7 +113,7 @@ float4 main( PFXVertToPix IN ) : TORQUE_TARGET0 } // Add the bloom effect. - sample += g_fBloomScale * bloom; + sample += saturate(g_fBloomScale * bloom); // Apply contrast sample.rgb = ((sample.rgb - 0.5f) * Contrast) + 0.5f;