Volumetric.frag.glsl 799 B

12345678910111213141516171819202122232425262728293031323334
  1. // Copyright (C) 2009-2016, Panagiotis Christopoulos Charitos and contributors.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. #include "shaders/Common.glsl"
  6. #include "shaders/Functions.glsl"
  7. layout(location = 0) in vec2 in_uv;
  8. layout(ANKI_TEX_BINDING(0, 0)) uniform sampler2D u_msDepthRt;
  9. layout(std140, ANKI_UBO_BINDING(0, 0)) uniform ubo0_
  10. {
  11. vec4 u_linearizePad2;
  12. vec4 u_fogColorFogFactor;
  13. };
  14. layout(location = 0) out vec3 out_color;
  15. vec3 fog(vec2 uv)
  16. {
  17. float depth = textureLod(u_msDepthRt, uv, 1.0).r;
  18. float linearDepth = linearizeDepthOptimal(depth, u_linearizePad2.x, u_linearizePad2.y);
  19. float t = linearDepth * u_fogColorFogFactor.w;
  20. return dither(u_fogColorFogFactor.rgb * t, 4.0);
  21. }
  22. void main()
  23. {
  24. out_color = fog(in_uv);
  25. }