1#import "Common/ShaderLib/Hdr.glsllib"
2
3varying vec2 texCoord;
4
5uniform sampler2D m_Texture;
6uniform sampler2D m_Lum;
7uniform sampler2D m_Lum2;
8
9uniform float m_A;
10uniform float m_White;
11uniform float m_BlendFactor;
12uniform float m_Gamma;
13
14void main() {
15    float avgLumA = HDR_DecodeLum( texture2D(m_Lum, vec2(0.0)) );
16    float avgLumB = HDR_DecodeLum( texture2D(m_Lum2, vec2(0.0)) );
17    float lerpedLum = mix(avgLumA, avgLumB, m_BlendFactor);
18
19    vec4 color = texture2D(m_Texture, texCoord);
20    vec3 c1 = HDR_ToneMap(color.rgb, lerpedLum, m_A, m_White);
21    //vec3 c2 = HDR_ToneMap2(color.rgb, lerpedLum, m_A * vec2(0.25), m_White);
22
23    //float l1 = HDR_GetLuminance(c1);
24    //float l2 = HDR_GetLuminance(c2);
25
26    //vec3 final = mix(c2, c1, clamp(l1, 0.0, 1.0));
27
28    //tonedColor = pow(tonedColor, vec3(m_Gamma));
29    gl_FragColor = vec4(c1, color.a);
30}
31
32