IndirectDiffuseProbes.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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/Renderer/RendererObject.h>
  7. #include <AnKi/Renderer/Utils/TraditionalDeferredShading.h>
  8. #include <AnKi/Collision/Forward.h>
  9. namespace anki {
  10. /// @addtogroup renderer
  11. /// @{
  12. ANKI_CVAR2(NumericCVar<U32>, Render, Idp, TileResolution, (ANKI_PLATFORM_MOBILE) ? 16 : 32, 8, 32, "GI tile resolution")
  13. ANKI_CVAR2(NumericCVar<U32>, Render, Idp, ShadowMapResolution, 128, 4, 2048, "GI shadowmap resolution")
  14. /// Ambient global illumination passes.
  15. ///
  16. /// It builds a volume clipmap with ambient GI information.
  17. class IndirectDiffuseProbes : public RendererObject
  18. {
  19. public:
  20. Error init();
  21. /// Populate the rendergraph.
  22. void populateRenderGraph(RenderingContext& ctx);
  23. RenderTargetHandle getCurrentlyRefreshedVolumeRt() const
  24. {
  25. ANKI_ASSERT(m_runCtx.m_probeVolumeHandle.isValid());
  26. return m_runCtx.m_probeVolumeHandle;
  27. }
  28. Bool hasCurrentlyRefreshedVolumeRt() const
  29. {
  30. return m_runCtx.m_probeVolumeHandle.isValid();
  31. }
  32. private:
  33. class
  34. {
  35. public:
  36. Array<RenderTargetDesc, kGBufferColorRenderTargetCount> m_colorRtDescrs;
  37. RenderTargetDesc m_depthRtDescr;
  38. } m_gbuffer; ///< G-buffer pass.
  39. class
  40. {
  41. public:
  42. RenderTargetDesc m_rtDescr;
  43. } m_shadowMapping;
  44. class LS
  45. {
  46. public:
  47. RenderTargetDesc m_rtDescr;
  48. TraditionalDeferredLightShading m_deferred;
  49. } m_lightShading; ///< Light shading.
  50. class
  51. {
  52. public:
  53. ShaderProgramResourcePtr m_prog;
  54. ShaderProgramPtr m_grProg;
  55. } m_irradiance; ///< Irradiance.
  56. static constexpr U32 kProbeCellRefreshesPerFrame = 2;
  57. U32 m_tileSize = 0;
  58. class
  59. {
  60. public:
  61. RenderTargetHandle m_probeVolumeHandle;
  62. } m_runCtx;
  63. Error initInternal();
  64. Error initGBuffer();
  65. Error initShadowMapping();
  66. Error initLightShading();
  67. Error initIrradiance();
  68. };
  69. /// @}
  70. } // end namespace anki