tonemap.frag 624 B

123456789101112131415161718192021222324
  1. uniform sampler2D tex;
  2. uniform float vignette_weight;
  3. out vec4 FragColor;
  4. vec3 getCIEYxy(vec3 rgbColor);
  5. vec3 getRGBFromCIEXxy(vec3 YxyColor);
  6. void main()
  7. {
  8. vec2 uv = gl_FragCoord.xy / screen;
  9. vec4 col = texture(tex, uv);
  10. // Uncharted2 tonemap with Auria's custom coefficients
  11. vec4 perChannel = (col * (6.9 * col + .5)) / (col * (5.2 * col + 1.7) + 0.06);
  12. perChannel = pow(perChannel, vec4(2.2));
  13. vec2 inside = uv - 0.5;
  14. float vignette = 1. - dot(inside, inside) * vignette_weight;
  15. vignette = clamp(pow(vignette, 0.8), 0., 1.);
  16. FragColor = vec4(perChannel.xyz * vignette, col.a);
  17. }