Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/skybox/Media/materials/programs/hdr_downscale3x3brightpass.glsl @ 393

Last change on this file since 393 was 390, checked in by landauf, 17 years ago

added materials

File size: 1.2 KB
Line 
1uniform sampler2D inRTT;
2uniform sampler2D inLum;
3uniform vec2 texelSize;
4
5varying vec2 uv;
6const vec4 BRIGHT_LIMITER = vec4(0.6, 0.6, 0.6, 0.0);
7
8// declare external function
9vec4 toneMap(in vec4 inColour, in float lum);
10
11void main(void)
12{
13    vec4 accum = vec4(0.0, 0.0, 0.0, 0.0);
14
15    accum += texture2D(inRTT, uv + texelSize * vec2(-1.0, -1.0));
16    accum += texture2D(inRTT, uv + texelSize * vec2( 0.0, -1.0));
17    accum += texture2D(inRTT, uv + texelSize * vec2( 1.0, -1.0));
18    accum += texture2D(inRTT, uv + texelSize * vec2(-1.0,  0.0));
19    accum += texture2D(inRTT, uv + texelSize * vec2( 0.0,  0.0));
20    accum += texture2D(inRTT, uv + texelSize * vec2( 1.0,  0.0));
21    accum += texture2D(inRTT, uv + texelSize * vec2(-1.0,  1.0));
22    accum += texture2D(inRTT, uv + texelSize * vec2( 0.0,  1.0));
23    accum += texture2D(inRTT, uv + texelSize * vec2( 1.0,  1.0));
24   
25        // take average of 9 samples
26        accum *= 0.1111111111111111;
27
28    // Reduce bright and clamp
29    accum = max(vec4(0.0, 0.0, 0.0, 1.0), accum - BRIGHT_LIMITER);
30
31        // Sample the luminence texture
32        vec4 lum = texture2D(inLum, vec2(0.5, 0.5));
33       
34        // Tone map result
35        gl_FragColor = toneMap(accum, lum.r);
36
37}
Note: See TracBrowser for help on using the repository browser.