Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/media/materials/programs/hdr_tonemap_util.glsl @ 5312

Last change on this file since 5312 was 5312, checked in by landauf, 15 years ago

added shaders (compositors, materials, cg programs and textures)

  • Property svn:eol-style set to native
File size: 654 bytes
Line 
1const float MIDDLE_GREY = 0.72;
2const float FUDGE = 0.001;
3const float L_WHITE = 1.5;
4
5/** Tone mapping function
6@note Only affects rgb, not a
7@param inColour The HDR colour
8@param lum The scene lumninence
9@returns Tone mapped colour
10*/
11vec4 toneMap(in vec4 inColour, in float lum)
12{
13        // From Reinhard et al
14        // "Photographic Tone Reproduction for Digital Images"
15       
16        // Initial luminence scaling (equation 2)
17    inColour.rgb *= MIDDLE_GREY / (FUDGE + lum);
18
19        // Control white out (equation 4 nom)
20    inColour.rgb *= (1.0 + inColour.rgb / L_WHITE);
21
22        // Final mapping (equation 4 denom)
23        inColour.rgb /= (1.0 + inColour.rgb);
24       
25        return inColour;
26
27}
28
29
Note: See TracBrowser for help on using the repository browser.