Reflections.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. namespace anki {
  8. /// @addtogroup renderer
  9. /// @{
  10. ANKI_CVAR2(BoolCVar, Render, Reflections, Rt, true, "Enable RT reflections")
  11. ANKI_CVAR2(BoolCVar, Render, Reflections, InlineRt, false, "Enable a cheap inline RT alternative path")
  12. ANKI_CVAR2(NumericCVar<F32>, Render, Reflections, RtMaxRayDistance, 100.0f, 1.0f, 10000.0f, "Max RT reflections ray distance")
  13. ANKI_CVAR2(NumericCVar<U32>, Render, Reflections, SsrStepIncrement, 32, 1, 256, "The number of steps for each loop")
  14. ANKI_CVAR2(NumericCVar<U32>, Render, Reflections, SsrMaxIterations, ANKI_PLATFORM_MOBILE ? 16 : 64, 1, 256, "Max SSR raymarching loop iterations")
  15. ANKI_CVAR2(NumericCVar<F32>, Render, Reflections, RoughnessCutoffToGiEdge0, 0.7f, 0.0f, 1.0f,
  16. "Before this roughness the reflections will never sample the GI probes")
  17. ANKI_CVAR2(NumericCVar<F32>, Render, Reflections, RoughnessCutoffToGiEdge1, 0.9f, 0.0f, 1.0f,
  18. "After this roughness the reflections will sample the GI probes")
  19. class Reflections : public RtMaterialFetchRendererObject
  20. {
  21. public:
  22. Reflections()
  23. {
  24. registerDebugRenderTarget("Reflections");
  25. }
  26. Error init();
  27. void populateRenderGraph(RenderingContext& ctx);
  28. void getDebugRenderTarget([[maybe_unused]] CString rtName, Array<RenderTargetHandle, U32(DebugRenderTargetRegister::kCount)>& handles,
  29. DebugRenderTargetDrawStyle& drawStyle) const override
  30. {
  31. handles[0] = m_runCtx.m_rt;
  32. drawStyle = DebugRenderTargetDrawStyle::kTonemap;
  33. }
  34. RenderTargetHandle getRt() const
  35. {
  36. return m_runCtx.m_rt;
  37. }
  38. public:
  39. ShaderProgramResourcePtr m_mainProg;
  40. ShaderProgramResourcePtr m_missProg;
  41. ShaderProgramPtr m_ssrGrProg;
  42. ShaderProgramPtr m_libraryGrProg;
  43. ShaderProgramPtr m_rtMaterialFetchInlineRtGrProg;
  44. ShaderProgramPtr m_spatialDenoisingGrProg;
  45. ShaderProgramPtr m_temporalDenoisingGrProg;
  46. ShaderProgramPtr m_verticalBilateralDenoisingGrProg;
  47. ShaderProgramPtr m_horizontalBilateralDenoisingGrProg;
  48. ShaderProgramPtr m_probeFallbackGrProg;
  49. ShaderProgramPtr m_tileClassificationGrProg;
  50. RenderTargetDesc m_transientRtDesc1;
  51. RenderTargetDesc m_transientRtDesc2;
  52. RenderTargetDesc m_hitPosAndDepthRtDesc;
  53. RenderTargetDesc m_hitPosRtDesc;
  54. RenderTargetDesc m_classTileMapRtDesc;
  55. /// 2 x DispatchIndirectArgs. 1st is for RT and 2nd for probe fallback
  56. BufferPtr m_indirectArgsBuffer;
  57. TexturePtr m_tex;
  58. Array<TexturePtr, 2> m_momentsTextures;
  59. Bool m_texImportedOnce = false;
  60. U32 m_sbtRecordSize = 0;
  61. U32 m_rayGenShaderGroupIdx = 0;
  62. U32 m_missShaderGroupIdx = 0;
  63. static constexpr U32 kTileSize = 32;
  64. class
  65. {
  66. public:
  67. RenderTargetHandle m_rt;
  68. } m_runCtx;
  69. };
  70. /// @}
  71. } // namespace anki