fboshader.vs 769 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #START VS
  2. #version 330 core
  3. layout (location = 0) in vec2 in_position;
  4. layout (location = 1) in vec2 in_uv;
  5. out vec2 uv;
  6. void main()
  7. {
  8. gl_Position = vec4(in_position.x, in_position.y, 0.0f, 1.0f);
  9. uv = in_uv;
  10. }
  11. #END VS
  12. #START FS
  13. #version 330 core
  14. in vec2 uv;
  15. out vec4 color;
  16. uniform sampler2D u_texture;
  17. vec3 aces_tonemap(vec3 x) {
  18. float a = 2.51;
  19. float b = 0.03;
  20. float c = 2.43;
  21. float d = 0.59;
  22. float e = 0.14;
  23. return clamp((x*(a*x+b))/(x*(c*x+d)+e), 0.0, 1.0);
  24. }
  25. const vec3 u_white_point = vec3(0.75, 0.75, 0.75);
  26. void main()
  27. {
  28. vec3 tex_color = textureLod(u_texture, uv, 0.0).rgb;
  29. if (length(tex_color) <= 0)
  30. discard;
  31. tex_color = vec3(1.0) - exp(-tex_color / u_white_point);
  32. color = vec4(aces_tonemap(tex_color), 1.0);
  33. }
  34. #END FS