-
Notifications
You must be signed in to change notification settings - Fork 0
/
filter_HDR_my.glsl
41 lines (33 loc) · 1.16 KB
/
filter_HDR_my.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
40
41
uniform sampler2D bgl_LuminanceTexture;
uniform sampler2D bgl_RenderedTexture;
uniform float HDRthreshold; // from 0 to 1; default = 0.5;
uniform float HDRamount; // from 0 to 1
vec2 texcoord = vec2(gl_TexCoord[0]).st;
void main(void)
{
vec4 value = texture2D(bgl_RenderedTexture, texcoord);
float mid_value = (value[0] + value[1] + value[2]) / 3.0;
vec4 shit = vec4(0.0, 1.0, 0.0, 1.0);
float amount = 100.0 - HDRamount * 100;
float a = -4.0;
float b = abs(a);
if (mid_value > HDRthreshold) {
gl_FragColor =
vec4(
value[0] + ((1.0 - value[0]) / amount),
value[1] + ((1.0 - value[1]) / amount),
value[2] + ((1.0 - value[2]) / amount),
value[3]);
}
if (mid_value < HDRthreshold) {
gl_FragColor =
vec4(
value[0] - ((1.0 - value[0]) / amount),
value[1] - ((1.0 - value[1]) / amount),
value[2] - ((1.0 - value[2]) / amount),
value[3]);
}
if (mid_value == HDRthreshold) {
gl_FragColor = value;
}
}