This repository has been archived on 2020-09-07. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
libs/qglengine/shaders/ds_tonemap.glsl

26 lines
448 B
GLSL

// vert //
void main(void) {
gl_Position = qgl_ftransform();
}
// frag //
uniform sampler2D tex_0;
uniform float gamma, frame_max;
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);
vec3 res = src.rgb;
float l = dot(res, luma) * 0.75;
float g = gamma / frame_max;
res /= l;
l = 1 - exp(-l*g);
res *= l;
qgl_FragColor = vec4(res, dot(res, luma));
}