-
-
Notifications
You must be signed in to change notification settings - Fork 16
/
uncharted2.glsl
39 lines (35 loc) · 966 Bytes
/
uncharted2.glsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
vec3 uncharted2Tonemap(vec3 x) {
float A = 0.15;
float B = 0.50;
float C = 0.10;
float D = 0.20;
float E = 0.02;
float F = 0.30;
float W = 11.2;
return ((x * (A * x + C * B) + D * E) / (x * (A * x + B) + D * F)) - E / F;
}
vec3 uncharted2(vec3 color) {
const float W = 11.2;
float exposureBias = 2.0;
vec3 curr = uncharted2Tonemap(exposureBias * color);
vec3 whiteScale = 1.0 / uncharted2Tonemap(vec3(W));
return curr * whiteScale;
}
float uncharted2Tonemap(float x) {
float A = 0.15;
float B = 0.50;
float C = 0.10;
float D = 0.20;
float E = 0.02;
float F = 0.30;
float W = 11.2;
return ((x * (A * x + C * B) + D * E) / (x * (A * x + B) + D * F)) - E / F;
}
float uncharted2(float color) {
const float W = 11.2;
const float exposureBias = 2.0;
float curr = uncharted2Tonemap(exposureBias * color);
float whiteScale = 1.0 / uncharted2Tonemap(W);
return curr * whiteScale;
}
#pragma glslify: export(uncharted2)