1 // Copyright 2001-2018 Crytek GmbH / Crytek Group. All rights reserved.
5 #include "Common/GraphicsPipelineStage.h"
6 #include "Common/PrimitiveRenderPass.h"
7 #include "Common/FullscreenPass.h"
8 //#include "Common/UtilityPasses.h"
10 #if !CRY_PLATFORM_ORBIS
11 #define FEATURE_RENDER_CLIPVOLUME_GEOMETRY_SHADER
14 class CClipVolumesStage
: public CGraphicsPipelineStage
17 static const uint32 MaxDeferredClipVolumes
= BIT_STENCIL_INSIDE_CLIPVOLUME
- 1; // Keep in sync with MAX_CLIPVOLUMES in DeferredShading.cfx / ShadowBlur.cfx
21 virtual ~CClipVolumesStage();
23 CGpuBuffer
* GetClipVolumeInfoBuffer () { return &m_clipVolumeInfoBuf
; }
24 CTexture
* GetClipVolumeStencilVolumeTexture() const { return m_pClipVolumeStencilVolumeTex
; }
26 bool IsOutdoorVisible() const { CRY_ASSERT(m_bClipVolumesValid
); return m_bOutdoorVisible
; }
31 bool IsStageActive(EShaderRenderingFlags flags
) const final
33 if (flags
& EShaderRenderingFlags::SHDF_FORWARD_MINIMAL
)
43 struct SClipVolumeInfo
48 void GenerateClipVolumeInfo();
51 void PrepareVolumetricFog();
52 void ExecuteVolumetricFog();
55 CPrimitiveRenderPass m_stencilPass
;
56 CPrimitiveRenderPass m_blendValuesPass
;
57 CFullscreenPass m_stencilResolvePass
;
59 #ifdef FEATURE_RENDER_CLIPVOLUME_GEOMETRY_SHADER
60 CPrimitiveRenderPass m_volumetricStencilPass
;
62 std::vector
<std::unique_ptr
<CPrimitiveRenderPass
>> m_volumetricStencilPassArray
;
63 std::vector
<std::unique_ptr
<CFullscreenPass
>> m_resolveVolumetricStencilPassArray
;
65 std::vector
<std::unique_ptr
<CFullscreenPass
>> m_jitteredDepthPassArray
;
67 CRenderPrimitive m_stencilPrimitives
[MaxDeferredClipVolumes
* 2];
68 CRenderPrimitive m_blendPrimitives
[MaxDeferredClipVolumes
];
69 #ifdef FEATURE_RENDER_CLIPVOLUME_GEOMETRY_SHADER
70 CRenderPrimitive m_stencilPrimitivesVolFog
[MaxDeferredClipVolumes
* 2];
73 CRY_ALIGN(16) Vec4 m_clipVolumeShaderParams
[MaxDeferredClipVolumes
];
74 uint32 m_nShaderParamCount
;
76 CGpuBuffer m_clipVolumeInfoBuf
;
78 CTexture
* m_pBlendValuesRT
;
79 CTexture
* m_pDepthTarget
;
81 CTexture
* m_pClipVolumeStencilVolumeTex
;
82 #ifdef FEATURE_RENDER_CLIPVOLUME_GEOMETRY_SHADER
83 CTexture
* m_depthTargetVolFog
;
85 std::vector
<CTexture
*> m_pClipVolumeStencilVolumeTexArray
;
87 std::vector
<ResourceViewHandle
> m_depthTargetArrayVolFog
;
91 float m_raymarchDistance
;
93 bool m_bClipVolumesValid
;
94 bool m_bBlendPassReady
;
95 bool m_bOutdoorVisible
;