fboshader.fs 523 B

123456789101112131415161718192021222324252627
  1. #version 330 core
  2. in vec2 uv;
  3. out vec4 color;
  4. uniform sampler2D u_texture;
  5. vec3 aces_tonemap(vec3 x) {
  6. float a = 2.51;
  7. float b = 0.03;
  8. float c = 2.43;
  9. float d = 0.59;
  10. float e = 0.14;
  11. return clamp((x*(a*x+b))/(x*(c*x+d)+e), 0.0, 1.0);
  12. }
  13. const vec3 u_white_point = vec3(0.75, 0.75, 0.75);
  14. void main()
  15. {
  16. vec3 tex_color = textureLod(u_texture, uv, 0.0).rgb;
  17. if (length(tex_color) <= 0)
  18. discard;
  19. tex_color = vec3(1.0) - exp(-tex_color / u_white_point);
  20. color = vec4(aces_tonemap(tex_color), 1.0);
  21. }