ClusteredShading.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // Copyright (C) 2009-2018, 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 <shaders/glsl_cpp_common/Clusterer.h>
  7. ANKI_BEGIN_NAMESPACE
  8. // Common uniforms between lights
  9. struct LightingUniforms
  10. {
  11. Vec4 m_unprojectionParams;
  12. Vec4 m_rendererSizeTimeNear;
  13. Vec4 m_cameraPosFar;
  14. ClustererMagicValues m_clustererMagicValues;
  15. UVec4 m_tileCount;
  16. Mat4 m_viewMat;
  17. Mat4 m_invViewMat;
  18. Mat4 m_projMat;
  19. Mat4 m_invProjMat;
  20. Mat4 m_viewProjMat;
  21. Mat4 m_invViewProjMat;
  22. Mat4 m_prevViewProjMat;
  23. Mat4 m_prevViewProjMatMulInvViewProjMat; // Used to re-project previous frames
  24. };
  25. // Point light
  26. struct PointLight
  27. {
  28. Vec4 m_posRadius; // xyz: Light pos in world space. w: The 1/(radius^2)
  29. Vec4 m_diffuseColorTileSize; // xyz: diff color, w: tile size in the shadow atlas
  30. Vec2 m_radiusPad1; // x: radius
  31. UVec2 m_atlasTiles; // x: encodes 6 uints with atlas tile indices in the x dir. y: same for y dir.
  32. };
  33. const U32 SIZEOF_POINT_LIGHT = 3 * SIZEOF_VEC4;
  34. // Spot light
  35. struct SpotLight
  36. {
  37. Vec4 m_posRadius; // xyz: Light pos in world space. w: The 1/(radius^2)
  38. Vec4 m_diffuseColorShadowmapId; // xyz: diff color, w: shadowmap tex ID
  39. Vec4 m_lightDirRadius; // xyz: light direction, w: radius
  40. Vec4 m_outerCosInnerCos;
  41. Mat4 m_texProjectionMat;
  42. };
  43. const U32 SIZEOF_SPOT_LIGHT = 4 * SIZEOF_VEC4 + SIZEOF_MAT4;
  44. // Representation of a reflection probe
  45. struct ReflectionProbe
  46. {
  47. Vec4 m_positionCubemapIndex; // xyz: Position of the prove in view space. w: Slice in u_reflectionsTex vector.
  48. Vec4 m_aabbMinPad1;
  49. Vec4 m_aabbMaxPad1;
  50. };
  51. const U32 SIZEOF_REFLECTION_PROBE = 2 * SIZEOF_VEC4;
  52. // Decal
  53. struct Decal
  54. {
  55. Vec4 m_diffUv;
  56. Vec4 m_normRoughnessUv;
  57. Mat4 m_texProjectionMat;
  58. Vec4 m_blendFactors;
  59. };
  60. const U32 SIZEOF_DECAL = 3 * SIZEOF_VEC4 + SIZEOF_MAT4;
  61. ANKI_END_NAMESPACE