mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-04-25 06:15:36 +00:00
Merge pull request #373 from Azaezel/alpha40_HDRfixes
get gl side HDR compiling, attempt clamp to keep bloom in range
This commit is contained in:
commit
e3b8c7b001
4 changed files with 12 additions and 26 deletions
|
|
@ -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];
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -166,20 +166,13 @@ vec2 parallaxOffsetDxtnm(sampler2D texMap, vec2 texCoord, vec3 negViewTS, float
|
|||
return offset;
|
||||
}
|
||||
|
||||
|
||||
/// The maximum value for 16bit per component integer HDR encoding.
|
||||
const float HDR_RGB16_MAX = 100.0;
|
||||
/// The maximum value for 10bit per component integer HDR encoding.
|
||||
const float HDR_RGB10_MAX = 4.0;
|
||||
|
||||
/// Encodes an HDR color for storage into a target.
|
||||
vec3 hdrEncode( vec3 _sample )
|
||||
{
|
||||
#if defined( TORQUE_HDR_RGB16 )
|
||||
|
||||
return _sample / HDR_RGB16_MAX;
|
||||
|
||||
#elif defined( TORQUE_HDR_RGB10 )
|
||||
#if defined( TORQUE_HDR_RGB10 )
|
||||
|
||||
return _sample / HDR_RGB10_MAX;
|
||||
|
||||
|
|
@ -200,11 +193,7 @@ vec4 hdrEncode( vec4 _sample )
|
|||
/// Decodes an HDR color from a target.
|
||||
vec3 hdrDecode( vec3 _sample )
|
||||
{
|
||||
#if defined( TORQUE_HDR_RGB16 )
|
||||
|
||||
return _sample * HDR_RGB16_MAX;
|
||||
|
||||
#elif defined( TORQUE_HDR_RGB10 )
|
||||
#if defined( TORQUE_HDR_RGB10 )
|
||||
|
||||
return _sample * HDR_RGB10_MAX;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue