MiscRendererTypes.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. // Copyright (C) 2009-present, 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/Common.h>
  7. ANKI_BEGIN_NAMESPACE
  8. /// Directional light (sun).
  9. struct DirectionalLight
  10. {
  11. Vec3 m_diffuseColor;
  12. F32 m_power;
  13. Vec3 m_direction;
  14. U32 m_shadowCascadeCount_31bit_active_1bit; ///< If shadowCascadeCount is zero then it doesn't cast shadow.
  15. Vec4 m_shadowCascadeDistances;
  16. Mat4 m_textureMatrices[kMaxShadowCascades];
  17. Vec4 m_cascadeFarPlanes;
  18. Vec4 m_cascadePcfTexelRadius; ///< The radius of the PCF. In UV space.
  19. };
  20. static_assert(kMaxShadowCascades == 4u); // Because m_shadowCascadeDistances and m_cascadeFarPlanes is a Vec4
  21. /// Common matrices and stuff.
  22. struct CommonMatrices
  23. {
  24. Mat3x4 m_cameraTransform;
  25. Mat3x4 m_view;
  26. Mat4 m_projection;
  27. Mat4 m_viewProjection;
  28. Mat4 m_jitter;
  29. Mat4 m_projectionJitter;
  30. Mat4 m_viewProjectionJitter;
  31. Mat4 m_invertedViewProjectionJitter; ///< To unproject in world space.
  32. Mat4 m_invertedViewProjection;
  33. Mat4 m_invertedProjectionJitter; ///< To unproject in view space.
  34. /// It's being used to reproject a clip space position of the current frame to the previous frame. Its value should be m_jitter *
  35. /// m_prevFrame.m_viewProjection * m_invertedViewProjectionJitter. At first it unprojects the current position to world space, all fine here. Then
  36. /// it projects to the previous frame as if the previous frame was using the current frame's jitter matrix.
  37. Mat4 m_reprojection;
  38. /// To unproject to view space. Jitter not considered.
  39. /// @code
  40. /// F32 z = m_unprojectionParameters.z / (m_unprojectionParameters.w + depth);
  41. /// Vec2 xy = ndc * m_unprojectionParameters.xy * z;
  42. /// pos = Vec3(xy, z);
  43. /// @endcode
  44. Vec4 m_unprojectionParameters;
  45. /// Part of the perspective projection matrix. Used in cheapPerspectiveUnprojection
  46. Vec4 m_projMat00_11_22_23;
  47. Vec2 m_jitterOffsetNdc;
  48. Vec2 m_padding;
  49. };
  50. struct Sky
  51. {
  52. Vec3 m_solidColor;
  53. U32 m_type;
  54. };
  55. struct Clipmap
  56. {
  57. UVec3 m_probeCounts;
  58. U32 m_probeCountsTotal;
  59. Vec3 m_size;
  60. U32 m_index;
  61. };
  62. /// Common constants for all passes.
  63. struct GlobalRendererConstants
  64. {
  65. Vec2 m_renderingSize;
  66. F32 m_time;
  67. U32 m_frame;
  68. Vec4 m_nearPlaneWSpace;
  69. Vec3 m_cameraPosition;
  70. F32 m_reflectionProbesMipCount;
  71. UVec2 m_tileCounts;
  72. U32 m_zSplitCount;
  73. F32 m_zSplitCountOverFrustumLength; ///< m_zSplitCount/(far-near)
  74. Vec2 m_zSplitMagic; ///< It's the "a" and "b" of computeZSplitClusterIndex(). See there for details.
  75. U32 m_lightVolumeLastZSplit;
  76. U32 m_padding1;
  77. UVec2 m_padding0;
  78. F32 m_near;
  79. F32 m_far;
  80. DirectionalLight m_directionalLight;
  81. CommonMatrices m_matrices;
  82. CommonMatrices m_previousMatrices;
  83. Sky m_sky;
  84. Clipmap m_indirectDiffuseClipmaps[kIndirectDiffuseClipmapCount];
  85. };
  86. // RT shadows
  87. struct RtShadowsDenoiseConstants
  88. {
  89. Mat4 m_invViewProjMat;
  90. F32 m_time;
  91. U32 m_minSampleCount;
  92. U32 m_maxSampleCount;
  93. F32 m_padding2;
  94. };
  95. struct RtShadowsSbtBuildConstants
  96. {
  97. U32 m_shaderHandleDwordSize;
  98. U32 m_sbtRecordDwordSize;
  99. U32 m_padding0;
  100. U32 m_padding1;
  101. };
  102. // Lens flare
  103. struct LensFlareSprite
  104. {
  105. Vec4 m_posScale; // xy: Position, zw: Scale
  106. Vec4 m_color;
  107. Vec4 m_depthPad3;
  108. };
  109. // Depth downscale
  110. struct DepthDownscaleConstants
  111. {
  112. Vec2 m_srcTexSizeOverOne;
  113. U32 m_threadgroupCount;
  114. U32 m_mipmapCount;
  115. };
  116. struct ReflectionConstants
  117. {
  118. U32 m_ssrMaxIterations;
  119. U32 m_ssrStepIncrement;
  120. Vec2 m_roughnessCutoffToGiEdges;
  121. };
  122. struct PixelFailedSsr
  123. {
  124. U32 m_pixel;
  125. U32 m_reflectionDirAndRoughness;
  126. U32 m_pdf_f16_rayDirT_f16;
  127. };
  128. // Vol fog
  129. struct VolumetricFogConstants
  130. {
  131. Vec3 m_fogDiffuse;
  132. F32 m_fogScatteringCoeff;
  133. F32 m_fogAbsorptionCoeff;
  134. F32 m_near;
  135. F32 m_far;
  136. F32 m_zSplitCountf;
  137. UVec3 m_volumeSize;
  138. F32 m_maxZSplitsToProcessf;
  139. };
  140. // Vol lighting
  141. struct VolumetricLightingConstants
  142. {
  143. F32 m_densityAtMinHeight;
  144. F32 m_densityAtMaxHeight;
  145. F32 m_minHeight;
  146. F32 m_oneOverMaxMinusMinHeight; // 1 / (maxHeight / minHeight)
  147. UVec3 m_volumeSize;
  148. F32 m_maxZSplitsToProcessf;
  149. };
  150. // SSAO
  151. struct SsaoConstants
  152. {
  153. F32 m_radius; ///< In meters.
  154. U32 m_sampleCount;
  155. Vec2 m_viewportSizef;
  156. Vec4 m_unprojectionParameters;
  157. F32 m_projectionMat00;
  158. F32 m_projectionMat11;
  159. F32 m_projectionMat22;
  160. F32 m_projectionMat23;
  161. Vec2 m_padding;
  162. F32 m_ssaoPower;
  163. U32 m_frameCount;
  164. Mat3x4 m_viewMat;
  165. };
  166. struct SsaoSpatialDenoiseConstants
  167. {
  168. Mat3x4 m_viewToWorldMat;
  169. Vec2 m_linearizeDepthParams;
  170. Vec2 m_padding;
  171. };
  172. struct LodAndRenderableIndex
  173. {
  174. U32 m_lod_2bit_renderableIndex_30bit;
  175. };
  176. ANKI_END_NAMESPACE