1 // Copyright 2001-2018 Crytek GmbH / Crytek Group. All rights reserved.
5 #include "Common/GraphicsPipelineStage.h"
6 #include "Common/FullscreenPass.h"
7 #include "Common/UtilityPasses.h"
9 class CWaterRipplesStage
: public CGraphicsPipelineStage
13 ~CWaterRipplesStage();
20 Vec4
GetWaterRippleLookupParam() const
25 CTexture
* GetWaterRippleTex() const;
27 bool IsVisible() const;
30 bool RefreshParameters();
31 void ExecuteWaterRipples(CTexture
* pTargetTex
, const D3DViewPort
& viewport
);
32 void UpdateAndDrawDebugInfo();
35 static const int32 sVertexCount
= 4;
36 static const int32 sTotalVertexCount
= sVertexCount
* SWaterRippleInfo::MaxWaterRipplesInScene
;
37 static const EDefaultInputLayouts::PreDefs sVertexFormat
= EDefaultInputLayouts::P3F_C4B_T2F
;
38 static const size_t sVertexStride
= sizeof(SVF_P3F_C4B_T2F
);
40 typedef SVF_P3F_C4B_T2F SVertex
;
42 struct SWaterRippleRecord
44 SWaterRippleInfo info
;
47 SWaterRippleRecord(const SWaterRippleInfo
& srcInfo
, float srcLifetime
)
49 , lifetime(srcLifetime
)
53 struct SWaterRippleConstants
59 _smart_ptr
<CTexture
> m_pTexWaterRipplesDDN
; // xy: wave propagation normals, z: frame t-2, w: frame t-1
60 _smart_ptr
<CTexture
> m_pTempTexture
;
62 CTypedConstantBuffer
<SWaterRippleConstants
, 256> m_constants
;
64 CFullscreenPass m_passSnapToCenter
;
65 CStretchRectPass m_passCopy
;
66 CFullscreenPass m_passWaterWavePropagation
;
67 CPrimitiveRenderPass m_passAddWaterRipples
;
68 CMipmapGenPass m_passMipmapGen
;
70 CRenderPrimitive m_ripplePrimitive
[SWaterRippleInfo::MaxWaterRipplesInScene
];
71 buffer_handle_t m_vertexBuffer
; // stored all ripples' vertices.
73 SResourceRegionMapping m_TempCopyParams
;
75 ICVar
* m_pCVarWaterRipplesDebug
;
77 CCryNameTSCRC m_ripplesGenTechName
;
78 CCryNameTSCRC m_ripplesHitTechName
;
82 float m_lastSpawnTime
;
83 float m_lastUpdateTime
;
85 float m_simGridSnapRange
;
92 bool m_bInitializeSim
;
95 std::vector
<SWaterRippleInfo
> m_waterRipples
;
96 std::vector
<SWaterRippleInfo
> m_waterRipplesMGPU
;
98 #if !defined(_RELEASE)
99 std::vector
<SWaterRippleRecord
> m_debugRippleInfos
;