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/qglview/shaders/hdr.frag

28 lines
623 B
GLSL

#version 150
uniform sampler2D t0;
uniform float exposure;
float tA = 0.15;
float tB = 0.50;
float tC = 0.10;
float tD = 0.20;
float tE = 0.02;
float tF = 0.30;
float tW = 11.2;
vec3 Uncharted2Tonemap(vec3 x) {
return ((x*(tA*x+tC*tB)+tD*tE)/(x*(tA*x+tB)+tD*tF))-tE/tF;
}
void main(void) {
vec3 inColor = texelFetch(t0, ivec2(gl_FragCoord.xy), 0).rgb;
inColor *= exposure;
float ExposureBias = 1;
vec3 curr = Uncharted2Tonemap(ExposureBias*inColor);
vec3 whiteScale = 1 / Uncharted2Tonemap(vec3(tW));
vec3 color = curr * whiteScale;
vec3 retColor = pow(color, vec3(1 / 2.2));
qgl_FragData[0].rgb = retColor;
}