2
0

RtShadows.glsl 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Copyright (C) 2009-2021, Panagiotis Christopoulos Charitos and contributors.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. #pragma once
  6. #include <AnKi/Shaders/Include/RtShadows.h>
  7. #include <AnKi/Shaders/PackFunctions.glsl>
  8. const F32 RT_SHADOWS_MAX_HISTORY_LENGTH = 31.0;
  9. UVec4 packRtShadows(F32 shadowFactors[MAX_RT_SHADOW_LAYERS])
  10. {
  11. const U32 a = newPackUnorm4x8(Vec4(shadowFactors[0], shadowFactors[1], shadowFactors[2], shadowFactors[3]));
  12. const U32 b = newPackUnorm4x8(Vec4(shadowFactors[4], shadowFactors[5], shadowFactors[6], shadowFactors[7]));
  13. return UVec4(a, b, 0, 0);
  14. }
  15. void unpackRtShadows(UVec4 packed, out F32 shadowFactors[MAX_RT_SHADOW_LAYERS])
  16. {
  17. const Vec4 a = newUnpackUnorm4x8(packed.x);
  18. const Vec4 b = newUnpackUnorm4x8(packed.y);
  19. shadowFactors[0] = a[0];
  20. shadowFactors[1] = a[1];
  21. shadowFactors[2] = a[2];
  22. shadowFactors[3] = a[3];
  23. shadowFactors[4] = b[0];
  24. shadowFactors[5] = b[1];
  25. shadowFactors[6] = b[2];
  26. shadowFactors[7] = b[3];
  27. }
  28. void zeroRtShadowLayers(out F32 shadowFactors[MAX_RT_SHADOW_LAYERS])
  29. {
  30. ANKI_UNROLL for(U32 i = 0u; i < MAX_RT_SHADOW_LAYERS; ++i)
  31. {
  32. shadowFactors[i] = 0.0;
  33. }
  34. }