Bloom.ankiprog 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <!--
  2. Copyright (C) 2009-2018, Panagiotis Christopoulos Charitos and contributors.
  3. All rights reserved.
  4. Code licensed under the BSD License.
  5. http://www.anki3d.org/LICENSE
  6. -->
  7. <shaderProgram>
  8. <shaders>
  9. <shader type="vert">
  10. <source><![CDATA[
  11. #include "shaders/QuadVert.glsl"
  12. ]]></source>
  13. </shader>
  14. <shader type="frag">
  15. <inputs>
  16. <input name="TEX_SIZE" type="vec2" const="1"/>
  17. </inputs>
  18. <source><![CDATA[
  19. #include "shaders/Common.glsl"
  20. #include "shaders/Tonemapping.glsl"
  21. // Vars
  22. layout(ANKI_TEX_BINDING(0, 0)) uniform sampler2D u_tex; ///< Its the IS RT
  23. layout(ANKI_UBO_BINDING(0, 0), std140) uniform u0_
  24. {
  25. vec4 u_thresholdScalePad2;
  26. };
  27. layout(ANKI_SS_BINDING(0, 0), std140) readonly buffer ss0_
  28. {
  29. vec4 u_averageLuminancePad3;
  30. };
  31. layout(location = 0) in vec2 in_uv;
  32. layout(location = 0) out vec4 out_color;
  33. void main()
  34. {
  35. const vec2 TEXEL_SIZE = 1.0 / TEX_SIZE;
  36. vec3 color = textureLod(u_tex, in_uv, 0.0).rgb;
  37. color += textureLod(u_tex, in_uv + TEXEL_SIZE, 0.0).rgb;
  38. color += textureLod(u_tex, in_uv - TEXEL_SIZE, 0.0).rgb;
  39. color += textureLod(u_tex, in_uv + vec2(TEXEL_SIZE.x, -TEXEL_SIZE.y), 0.0).rgb;
  40. color += textureLod(u_tex, in_uv + vec2(-TEXEL_SIZE.x, TEXEL_SIZE.y), 0.0).rgb;
  41. color /= 5.0;
  42. color = tonemap(color, u_averageLuminancePad3.x, u_thresholdScalePad2.x) * u_thresholdScalePad2.y;
  43. out_color = vec4(color, 0.25);
  44. }
  45. ]]></source>
  46. </shader>
  47. </shaders>
  48. </shaderProgram>