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