private void ExecuteRendering(WaterRenderingMode renderingMode, Camera camera, WaterRenderingVisibleArea visibleArea, Color backgroundColor, bool hdr, bool msaa, int extraLayersToIgnoreMask = 0) { #if GAME_2D_WATER_KIT_LWRP || GAME_2D_WATER_KIT_URP renderingMode.Render(_renderingContext, camera, visibleArea, backgroundColor, hdr, msaa, extraLayersToIgnoreMask); #else renderingMode.Render(camera, visibleArea, backgroundColor, hdr, msaa, extraLayersToIgnoreMask); #endif }
internal void Render(Camera currentRenderingCamera) { bool renderRefraction = _materialModule.IsRefractionEnabled; bool renderReflection = _materialModule.IsReflectionEnabled; bool isValidWaterSize = _mainModule.Width > 0f && _mainModule.Height > 0f; if (!currentRenderingCamera || !isValidWaterSize || !(renderReflection || renderRefraction)) { return; } var largeWaterAreaManager = _mainModule.LargeWaterAreaManager; bool isConnectedToLargeWaterArea = largeWaterAreaManager != null; if (isConnectedToLargeWaterArea && largeWaterAreaManager.HasAlreadyRenderedCurrentFrame(currentRenderingCamera)) { GetCurrentFrameRenderInformationFromLargeWaterAreaManager(largeWaterAreaManager, renderRefraction, renderReflection); return; } _renderingCameraFrustum.UpdateFrustum(currentRenderingCamera); ComputeVisibleAreas(currentRenderingCamera, !isConnectedToLargeWaterArea ? _meshModule.Bounds : largeWaterAreaManager.GetWaterObjectsBoundsRelativeToSpecifiedWaterObject(_mainModule)); int pixelLightCount = QualitySettings.pixelLightCount; if (!_renderPixelLights) { QualitySettings.pixelLightCount = 0; } Color backgroundColor = currentRenderingCamera.backgroundColor; backgroundColor.a = 0f; float pixelsPerUnit = currentRenderingCamera.pixelHeight / _renderingCameraFrustum.WorldSpace.Height; if (!_materialModule.IsFakePerspectiveEnabled) { if (renderRefraction) { _refraction.Render(_fullWaterVisibleArea, backgroundColor, pixelsPerUnit); _materialModule.SetRefractionRenderTexture(_refraction.RenderTexture); } if (renderReflection) { _reflection.Render(_fullWaterVisibleArea, backgroundColor, pixelsPerUnit); _materialModule.SetReflectionRenderTexture(_reflection.RenderTexture); } } else { if (renderRefraction) { _refraction.Render(_fullWaterVisibleArea, backgroundColor, pixelsPerUnit, _refractionPartiallySubmergedObjects.CullingMask); _materialModule.SetRefractionRenderTexture(_refraction.RenderTexture); _refractionPartiallySubmergedObjects.Render(_fullWaterVisibleArea, _transparentBackgroundColor, pixelsPerUnit); _materialModule.SetRefractionPartiallySubmergedObjectsRenderTexture(_refractionPartiallySubmergedObjects.RenderTexture); } if (renderReflection) { _reflection.Render(_surfaceVisibleArea, backgroundColor, pixelsPerUnit, _reflectionPartiallySubmergedObjects.CullingMask); _materialModule.SetReflectionRenderTexture(_reflection.RenderTexture); _reflectionPartiallySubmergedObjects.Render(_surfaceBelowSubmergeLevelVisibleArea, _transparentBackgroundColor, pixelsPerUnit); _materialModule.SetReflectionPartiallySubmergedObjectsRenderTexture(_reflectionPartiallySubmergedObjects.RenderTexture); } } QualitySettings.pixelLightCount = pixelLightCount; Matrix4x4 worldToVisibleAreaMatrix = Matrix4x4.Inverse(Matrix4x4.TRS(_fullWaterVisibleArea.Position, _fullWaterVisibleArea.Rotation, Vector3.one)); _materialModule.SetWaterMatrix(_fullWaterVisibleArea.ProjectionMatrix * worldToVisibleAreaMatrix * _mainModule.LocalToWorldMatrix); _materialModule.SetReflectionLowerLimit(_mainModule.Height * 0.5f); _materialModule.ValidateMaterialPropertyBlock(); if (isConnectedToLargeWaterArea) { SetCurrentFrameRenderInformationToLargeWaterAreaManager(largeWaterAreaManager, renderRefraction, renderReflection, _fullWaterVisibleArea.ProjectionMatrix * worldToVisibleAreaMatrix, currentRenderingCamera); } }