33 lines
671 B
GLSL
33 lines
671 B
GLSL
// vert //
|
|
|
|
void main(void) {
|
|
gl_Position = qgl_ftransform();
|
|
}
|
|
|
|
|
|
// frag //
|
|
|
|
uniform sampler2D tex_0, tex_sum;
|
|
uniform float exposure;
|
|
|
|
const vec3 luma = vec3(0.299, 0.587, 0.114);
|
|
|
|
void main(void) {
|
|
ivec2 tc = ivec2(gl_FragCoord.xy);
|
|
vec4 src = texelFetch(tex_0, tc, 0);
|
|
vec4 sum = texelFetch(tex_sum, ivec2(0,0), 0);
|
|
vec3 res = src.rgb;
|
|
float l = dot(res, luma);
|
|
float g = exposure / dot(sum.rgb, luma);
|
|
res /= l;
|
|
//res = log(res + vec3(2.)) - log(vec3(2.));
|
|
//res = pow(res,vec3(1/2.2));
|
|
//l = pow(l,1/2.2);
|
|
l = 1 - exp(-l*g);
|
|
//l /= 100;
|
|
//res = pow(res,vec3(2.2));
|
|
//l = pow(l,2.2);
|
|
qgl_FragColor.rgb = res * l;
|
|
//qgl_FragColor.rgb = sum.rgb*10;
|
|
}
|