/* * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or * its licensors. * * For complete copyright and license terms please see the LICENSE at the root of this * distribution (the "License"). All use of this software is governed by the License, * or, if provided, by the license below or the license accompanying this file. Do not * remove or modify any license notices. This file is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * */ // Original file Copyright Crytek GMBH or its affiliates, used under license. #ifndef CRYINCLUDE_CRY3DENGINE_TERRAIN_WATER_H #define CRYINCLUDE_CRY3DENGINE_TERRAIN_WATER_H #pragma once #include #define CYCLE_BUFFERS_NUM 4 class COcean: public IRenderNode , public Cry3DEngineBase { public: COcean(_smart_ptr pMat, float fWaterLevel); ~COcean(); void SetWaterLevel(float fWaterLevel); //In the future when STerrainInfo doesn't keep record of the water level this can be deleted. static void SetWaterLevelInfo(float fWaterLevelInfo) { m_fWaterLevelInfo = fWaterLevelInfo; } static float GetWaterLevelInfo() { return m_fWaterLevelInfo; } void Create(); void Update(const SRenderingPassInfo& passInfo); void Render(const SRenderingPassInfo& passInfo); bool IsVisible(const SRenderingPassInfo& passInfo); void SetLastFov(float fLastFov) {m_fLastFov = fLastFov; } static void SetTimer(ITimer* pTimer); float GetWaterLevel() { return m_fWaterLevel; } static float GetWave(const Vec3& pPosition, int32 nFrameID); static uint32 GetVisiblePixelsCount(); int32 GetMemoryUsage(); // fake IRenderNode implementation virtual EERType GetRenderNodeType(); virtual const char* GetEntityClassName(void) const { return "Ocean"; } virtual const char* GetName(void) const { return "Ocean"; } virtual Vec3 GetPos(bool) const; virtual void Render(const SRendParams&, const SRenderingPassInfo& passInfo) {} virtual void SetMaterial(_smart_ptr pMat) override; virtual _smart_ptr GetMaterial(Vec3* pHitPos = NULL); virtual _smart_ptr GetMaterialOverride() { return m_pMaterial; } virtual float GetMaxViewDist() { return 1000000.f; } virtual void GetMemoryUsage(ICrySizer* pSizer) const{} virtual const AABB GetBBox() const { return AABB(Vec3(-1000000.f, -1000000.f, -1000000.f), Vec3(1000000.f, 1000000.f, 1000000.f)); } virtual void SetBBox(const AABB& WSBBox) { } virtual void FillBBox(AABB& aabb); virtual void OffsetPosition(const Vec3& delta) {} private: void RenderFog(const SRenderingPassInfo& passInfo); void RenderBottomCap(const SRenderingPassInfo& passInfo); void GetOceanGridSize(int& outX, int& outY) const; private: static bool IsWaterVisibleOcclusionCheck(); // Ocean data _smart_ptr m_pMaterial; _smart_ptr m_pRenderMesh; PodArray m_pMeshVerts; PodArray m_pMeshIndices; int32 m_nPrevGridDim; int32 m_nVertsCount; int32 m_nIndicesCount; int32 m_nTessellationType; int32 m_nTessellationTiles; // Ocean bottom cap data _smart_ptr< IMaterial > m_pBottomCapMaterial; _smart_ptr m_pBottomCapRenderMesh; PodArray m_pBottomCapVerts; PodArray m_pBottomCapIndices; // Visibility data CCamera m_Camera; class CREOcclusionQuery* m_pREOcclusionQueries[CYCLE_BUFFERS_NUM]; IShader* m_pShaderOcclusionQuery; float m_fLastFov; float m_fLastVisibleFrameTime; int32 m_nLastVisibleFrameId; static uint32 m_nVisiblePixelsCount; float m_fWaterLevel; float m_fRECustomData[12]; // used for passing data to renderer float m_fREOceanBottomCustomData[8]; // used for passing data to renderer AZ::Vector2 m_windUvTransform; // used for texture offset due to wind bool m_bOceanFFT; // Ocean fog related members CREWaterVolume::SParams m_wvParams[RT_COMMAND_BUF_COUNT]; CREWaterVolume::SOceanParams m_wvoParams[RT_COMMAND_BUF_COUNT]; _smart_ptr< IMaterial > m_pFogIntoMat; _smart_ptr< IMaterial > m_pFogOutofMat; _smart_ptr< IMaterial > m_pFogIntoMatLowSpec; _smart_ptr< IMaterial > m_pFogOutofMatLowSpec; CREWaterVolume* m_pWVRE[RT_COMMAND_BUF_COUNT]; std::vector m_wvVertices[RT_COMMAND_BUF_COUNT]; std::vector m_wvIndices[RT_COMMAND_BUF_COUNT]; int32 m_swathWidth; bool m_bUsingFFT; bool m_bUseTessHW; static ITimer* m_pTimer; static CREWaterOcean* m_pOceanRE; static float m_fWaterLevelInfo; }; #endif // CRYINCLUDE_CRY3DENGINE_TERRAIN_WATER_H