Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/branches/Shader_HS18/programs/Example/GLSLES/hdr_finalToneMapping.glsles @ 12091

Last change on this file since 12091 was 12091, checked in by wiesep, 5 years ago

Updated programs and adjusted Material to work with GLSL>150

File size: 1.2 KB
Line 
1#version 100
2precision mediump int;
3precision mediump float;
4
5uniform sampler2D inRTT;
6uniform sampler2D inBloom;
7uniform sampler2D inLum;
8
9varying vec2 uv;
10
11const float MIDDLE_GREY = 0.72;
12const float FUDGE = 0.001;
13const float L_WHITE = 1.5;
14
15/** Tone mapping function
16@note Only affects rgb, not a
17@param inColour The HDR colour
18@param lum The scene lumninence
19@returns Tone mapped colour
20*/
21vec4 toneMap(in vec4 inColour, in float lum)
22{
23        // From Reinhard et al
24        // "Photographic Tone Reproduction for Digital Images"
25       
26        // Initial luminence scaling (equation 2)
27    inColour.rgb *= MIDDLE_GREY / (FUDGE + lum);
28
29        // Control white out (equation 4 nom)
30    inColour.rgb *= (1.0 + inColour.rgb / L_WHITE);
31
32        // Final mapping (equation 4 denom)
33        inColour.rgb /= (1.0 + inColour.rgb);
34       
35        return inColour;
36}
37
38void main(void)
39{
40        // Get main scene colour
41    vec4 sceneCol = texture2D(inRTT, uv);
42
43        // Get luminence value
44        vec4 lum = texture2D(inLum, vec2(0.5, 0.5));
45
46        // tone map this
47        vec4 toneMappedSceneCol = toneMap(sceneCol, lum.r);
48       
49        // Get bloom colour
50    vec4 bloom = texture2D(inBloom, uv);
51
52        // Add scene & bloom
53        gl_FragColor = vec4(toneMappedSceneCol.rgb + bloom.rgb, 1.0);
54}
Note: See TracBrowser for help on using the repository browser.