Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

Diff Revisions 169 vs 170 for /trunk/assets/shaders/GLSL/bright.glsl

Diff revisions: vs.
  @@ -12,10 +12,40 @@
12 12 out vec4 _colorOut;
13 13
14 14 uniform sampler2D texScreen;
15 - uniform float whitePoint = 0.95;
15 + uniform sampler2D texExposure;
16 + uniform sampler2D texPrevExposure;
17 + uniform int exposureMipLevel;
18 +
19 + uniform bool toneMap = false;
20 + uniform bool luminancePass = false;
21 +
22 + uniform float whitePoint = 0.9;
23 +
24 + vec3 Uncharted2Tonemap(vec3 x)
25 + {
26 + float A = 0.15;
27 + float B = 0.50;
28 + float C = 0.10;
29 + float D = 0.20;
30 + float E = 0.02;
31 + float F = 0.30;
32 +
33 + return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;
34 + }
16 35
17 36 void main(){
18 37 vec3 value = texture(texScreen, _texCoord).rgb;
19 38
20 - _colorOut = clamp(sign(((value.r + value.g + value.b)/3.0) - whitePoint) * vec4(1.0), 0.0, 1.0);
39 + if(luminancePass){
40 + float PreviousExposure = texture(texPrevExposure, vec2(0.5, 0.5)).r;
41 + float TargetExposure = 0.5 / clamp(dot(value, vec3(0.299, 0.587, 0.114)), 0.1, 0.9);
42 + _colorOut.r = PreviousExposure + (TargetExposure - PreviousExposure) * 0.01;
43 + }else{
44 + if(toneMap) {
45 + float exposure = textureLod(texExposure, vec2(0.5,0.5), exposureMipLevel).r;
46 + _colorOut = vec4(Uncharted2Tonemap(value * exposure) / Uncharted2Tonemap(vec3(whitePoint)) , 1.0);
47 + }else{
48 + _colorOut = clamp(sign(((value.r + value.g + value.b)/3.0) - whitePoint) * vec4(1.0), 0.0, 1.0);
49 + }
50 + }
21 51 }