VolumetricFog.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. // Copyright (C) 2009-2021, 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. /// VolumetricFog effects.
  11. class VolumetricFog : public RendererObject
  12. {
  13. public:
  14. VolumetricFog(Renderer* r)
  15. : RendererObject(r)
  16. {
  17. }
  18. ~VolumetricFog()
  19. {
  20. }
  21. ANKI_USE_RESULT Error init(const ConfigSet& config);
  22. void setFogParticleColor(const Vec3& col)
  23. {
  24. m_fogDiffuseColor = col;
  25. }
  26. const Vec3& getFogParticleColor() const
  27. {
  28. return m_fogDiffuseColor;
  29. }
  30. void setParticleDensity(F32 d)
  31. {
  32. m_fogDensity = d;
  33. }
  34. F32 getParticleDensity() const
  35. {
  36. return m_fogDensity;
  37. }
  38. /// Populate the rendergraph.
  39. void populateRenderGraph(RenderingContext& ctx);
  40. RenderTargetHandle getRt() const
  41. {
  42. return m_runCtx.m_rt;
  43. }
  44. const Array<U32, 3>& getVolumeSize() const
  45. {
  46. return m_volumeSize;
  47. }
  48. /// Get the last cluster split in Z axis that will be affected by lighting.
  49. U32 getFinalClusterInZ() const
  50. {
  51. return m_finalZSplit;
  52. }
  53. private:
  54. ShaderProgramResourcePtr m_prog;
  55. ShaderProgramPtr m_grProg;
  56. RenderTargetDescription m_rtDescr;
  57. U32 m_finalZSplit = 0;
  58. Array<U32, 2> m_workgroupSize = {};
  59. Array<U32, 3> m_volumeSize;
  60. Vec3 m_fogDiffuseColor = Vec3(1.0f);
  61. F32 m_fogDensity = 0.9f;
  62. F32 m_fogScatteringCoeff = 0.01f;
  63. F32 m_fogAbsorptionCoeff = 0.02f;
  64. class
  65. {
  66. public:
  67. RenderTargetHandle m_rt;
  68. } m_runCtx; ///< Runtime context.
  69. void run(const RenderingContext& ctx, RenderPassWorkContext& rgraphCtx);
  70. };
  71. /// @}
  72. } // end namespace anki