ClusterLightCommon.glsl 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. #ifndef ANKI_SHADERS_CLUSTER_LIGHT_COMMON_GLSL
  6. #define ANKI_SHADERS_CLUSTER_LIGHT_COMMON_GLSL
  7. #include "shaders/LightFunctions.glsl"
  8. // Common uniforms between lights
  9. struct LightingUniforms
  10. {
  11. vec4 projectionParams;
  12. vec4 rendererSizeTimePad1;
  13. vec4 nearFarClustererMagicPad1;
  14. mat4 viewMat;
  15. mat3 invViewRotation;
  16. uvec4 tileCount;
  17. };
  18. // Point light
  19. struct PointLight
  20. {
  21. vec4 posRadius; // xyz: Light pos in eye space. w: The -1/radius
  22. vec4 diffuseColorShadowmapId; // xyz: diff color, w: shadowmap tex ID
  23. vec4 specularColorTexId; // xyz: spec color, w: diffuse tex ID
  24. };
  25. // Spot light
  26. struct SpotLight
  27. {
  28. vec4 posRadius; // xyz: Light pos in eye space. w: The -1/radius
  29. vec4 diffuseColorShadowmapId; // xyz: diff color, w: shadowmap tex ID
  30. vec4 specularColorTexId; // xyz: spec color, w: diffuse tex ID
  31. vec4 lightDir;
  32. vec4 outerCosInnerCos;
  33. mat4 texProjectionMat;
  34. };
  35. // Representation of a reflection probe
  36. struct ReflectionProbe
  37. {
  38. // Position of the prove in view space. Radius of probe squared
  39. vec4 positionRadiusSq;
  40. // Slice in u_reflectionsTex vector.
  41. vec4 cubemapIndexPad3;
  42. };
  43. // Decal
  44. struct Decal
  45. {
  46. vec4 diffUv;
  47. vec4 normRoughnessUv;
  48. mat4 texProjectionMat;
  49. vec4 blendFactors;
  50. };
  51. layout(ANKI_UBO_BINDING(LIGHT_SET, LIGHT_UBO_BINDING), std140, row_major) uniform u0_
  52. {
  53. LightingUniforms u_lightingUniforms;
  54. };
  55. #ifdef FRAGMENT_SHADER
  56. layout(ANKI_UBO_BINDING(LIGHT_SET, LIGHT_UBO_BINDING + 1), std140) uniform u1_
  57. {
  58. PointLight u_pointLights[UBO_MAX_SIZE / (3 * 4 * 4)];
  59. };
  60. layout(ANKI_UBO_BINDING(LIGHT_SET, LIGHT_UBO_BINDING + 2), std140, row_major) uniform u2_
  61. {
  62. SpotLight u_spotLights[UBO_MAX_SIZE / (9 * 4 * 4)];
  63. };
  64. #ifdef LIGHT_INDIRECT
  65. layout(std140, row_major, ANKI_UBO_BINDING(LIGHT_SET, LIGHT_UBO_BINDING + 3)) uniform u3_
  66. {
  67. ReflectionProbe u_reflectionProbes[UBO_MAX_SIZE / (2 * 4 * 4)];
  68. };
  69. #endif
  70. #ifdef LIGHT_DECALS
  71. layout(std140, row_major, ANKI_UBO_BINDING(LIGHT_SET, LIGHT_UBO_BINDING + 4)) uniform u4_
  72. {
  73. Decal u_decals[UBO_MAX_SIZE / ((4 + 16) * 4)];
  74. };
  75. #endif
  76. layout(ANKI_SS_BINDING(LIGHT_SET, LIGHT_SS_BINDING + 0), std430) readonly buffer s0_
  77. {
  78. uint u_clusters[];
  79. };
  80. layout(std430, ANKI_SS_BINDING(LIGHT_SET, LIGHT_SS_BINDING + 1)) readonly buffer s1_
  81. {
  82. uint u_lightIndices[];
  83. };
  84. layout(ANKI_TEX_BINDING(LIGHT_SET, LIGHT_TEX_BINDING)) uniform highp sampler2DArrayShadow u_spotMapArr;
  85. layout(ANKI_TEX_BINDING(LIGHT_SET, LIGHT_TEX_BINDING + 1)) uniform highp samplerCubeArrayShadow u_omniMapArr;
  86. #ifdef LIGHT_INDIRECT
  87. layout(ANKI_TEX_BINDING(LIGHT_SET, LIGHT_TEX_BINDING + 2)) uniform samplerCubeArray u_reflectionsTex;
  88. layout(ANKI_TEX_BINDING(LIGHT_SET, LIGHT_TEX_BINDING + 3)) uniform samplerCubeArray u_irradianceTex;
  89. layout(ANKI_TEX_BINDING(LIGHT_SET, LIGHT_TEX_BINDING + 4)) uniform sampler2D u_integrationLut;
  90. #endif
  91. #endif // FRAGMENT_SHADER
  92. #endif