get gl side HDR compiling, attempt clamp to keep bloom in range

This commit is contained in:
AzaezelX 2020-10-30 00:15:08 -05:00
parent 1e9df5f415
commit 5be1b77791
3 changed files with 10 additions and 13 deletions

View file

@ -22,7 +22,7 @@
#define IN_GLSL #define IN_GLSL
#include "core/rendering/shaders/shdrConsts.h" #include "core/rendering/shaders/shdrConsts.h"
#include ".core/rendering/shaders/gl/hlslCompat.glsl" #include "core/rendering/shaders/gl/hlslCompat.glsl"
#include "shadergen:/autogenConditioners.h" #include "shadergen:/autogenConditioners.h"
in vec4 texCoords[8]; in vec4 texCoords[8];

View file

@ -69,28 +69,25 @@ float3 ACESFilm( float3 x )
const float c = 2.43; const float c = 2.43;
const float d = 0.59; const float d = 0.59;
const float e = 0.14; 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 tonemap(vec3 c)
{ {
vec3 colorOut = c; vec3 colorOut = c;
if(g_fTonemapMode == 1.0) if(g_fTonemapMode == 1.0)
{ {
const float W = 11.2; const float W = 11.2;
float ExposureBias = 2.0f; float ExposureBias = 2.0f;
float ExposureAdjust = 1.5f; //float ExposureAdjust = 1.5f;
c *= ExposureAdjust; //c *= ExposureAdjust;
vec3 curr = Uncharted2Tonemap(ExposureBias*c); colorOut = Uncharted2Tonemap(ExposureBias*colorOut);
vec3 whiteScale = 1.0f / Uncharted2Tonemap(vec3(W,W,W)); colorOut = colorOut * (1.0f / Uncharted2Tonemap(vec3(W,W,W)));
colorOut = curr*whiteScale;
}
} }
else if(g_fTonemapMode == 2.0) else if(g_fTonemapMode == 2.0)
{ {
colorOut = ACESFilm(c); colorOut = ACESFilm(colorOut);
} }
return colorOut; return colorOut;
@ -123,7 +120,7 @@ void main()
} }
// Add the bloom effect. // 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 // Apply contrast
_sample.rgb = ((_sample.rgb - 0.5f) * Contrast) + 0.5f; _sample.rgb = ((_sample.rgb - 0.5f) * Contrast) + 0.5f;

View file

@ -113,7 +113,7 @@ float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
} }
// Add the bloom effect. // Add the bloom effect.
sample += g_fBloomScale * bloom; sample += saturate(g_fBloomScale * bloom);
// Apply contrast // Apply contrast
sample.rgb = ((sample.rgb - 0.5f) * Contrast) + 0.5f; sample.rgb = ((sample.rgb - 0.5f) * Contrast) + 0.5f;