private void ComputeVisibleAreas(Bounds waterfallBounds) { _clipeePoints.Clear(); _clipeePoints.Add(_renderingCameraFrustum.TopLeft); _clipeePoints.Add(_renderingCameraFrustum.TopRight); _clipeePoints.Add(_renderingCameraFrustum.BottomRight); _clipeePoints.Add(_renderingCameraFrustum.BottomLeft); bool isRenderingCameraFullyContainedInWaterBox = true; //Finding visible Waterfall Area Vector2 waterfallBoundsMin = waterfallBounds.min; Vector2 waterfallBoundsMax = waterfallBounds.max; //Clip camera frustrum against waterfall box edges to find the visible water area //top edge isRenderingCameraFullyContainedInWaterBox &= WaterUtility.ClipPointsAgainstAABBEdge(_clipeePoints, isBottomOrTopEdge: true, isBottomOrLeftEdge: false, edgePosition: waterfallBoundsMax.y); //right edge isRenderingCameraFullyContainedInWaterBox &= WaterUtility.ClipPointsAgainstAABBEdge(_clipeePoints, isBottomOrTopEdge: false, isBottomOrLeftEdge: false, edgePosition: waterfallBoundsMax.x); //bottom edge isRenderingCameraFullyContainedInWaterBox &= WaterUtility.ClipPointsAgainstAABBEdge(_clipeePoints, isBottomOrTopEdge: true, isBottomOrLeftEdge: true, edgePosition: waterfallBoundsMin.y); //left edge isRenderingCameraFullyContainedInWaterBox &= WaterUtility.ClipPointsAgainstAABBEdge(_clipeePoints, isBottomOrTopEdge: false, isBottomOrLeftEdge: true, edgePosition: waterfallBoundsMin.x); _visibleArea.UpdateArea(_clipeePoints, _renderingCameraFrustum, isRenderingCameraFullyContainedInWaterBox, true, _farClipPlane); }
private void ComputeVisibleAreas(Bounds waterBounds) { var materialModule = _materialModule as WaterMaterialModule; bool isReflectionEnabled = materialModule.IsReflectionEnabled; _clipeePoints.Clear(); _clipeePoints.Add(_renderingCameraFrustum.TopLeft); _clipeePoints.Add(_renderingCameraFrustum.TopRight); _clipeePoints.Add(_renderingCameraFrustum.BottomRight); _clipeePoints.Add(_renderingCameraFrustum.BottomLeft); bool isRenderingCameraFullyContainedInWaterBox = true; //Finding visible Water Area Vector2 waterBoundsMin = waterBounds.min; Vector2 waterBoundsMax = waterBounds.max; //Clip camera frustrum against water box edges to find the visible water area //top edge isRenderingCameraFullyContainedInWaterBox &= WaterUtility.ClipPointsAgainstAABBEdge(_clipeePoints, isBottomOrTopEdge: true, isBottomOrLeftEdge: false, edgePosition: waterBoundsMax.y); //right edge isRenderingCameraFullyContainedInWaterBox &= WaterUtility.ClipPointsAgainstAABBEdge(_clipeePoints, isBottomOrTopEdge: false, isBottomOrLeftEdge: false, edgePosition: waterBoundsMax.x); //bottom edge isRenderingCameraFullyContainedInWaterBox &= WaterUtility.ClipPointsAgainstAABBEdge(_clipeePoints, isBottomOrTopEdge: true, isBottomOrLeftEdge: true, edgePosition: waterBoundsMin.y); //left edge isRenderingCameraFullyContainedInWaterBox &= WaterUtility.ClipPointsAgainstAABBEdge(_clipeePoints, isBottomOrTopEdge: false, isBottomOrLeftEdge: true, edgePosition: waterBoundsMin.x); bool isFakePerspectiveEnabled = materialModule.IsFakePerspectiveEnabled; bool computePixelSize = !Refraction.RenderTextureUseFixedSize || !(isFakePerspectiveEnabled ? RefractionPartiallySubmergedObjects.RenderTextureUseFixedSize : Reflection.RenderTextureUseFixedSize); _wholeWaterVisibleArea.UpdateArea(_clipeePoints, _renderingCameraFrustum, isRenderingCameraFullyContainedInWaterBox, computePixelSize, _farClipPlane, true, isReflectionEnabled && !isFakePerspectiveEnabled, reflectionYOffset: ReflectionYOffset, reflectionZOffset: ReflectionZOffset, reflectionAxis: -waterBoundsMin.y, reflectionFrustumHeightScalingFactor: Reflection.ViewingFrustumHeightScalingFactor); if (isFakePerspectiveEnabled) { float waterBoxHeight = waterBoundsMax.y - waterBoundsMin.y; bool computeRefractionProperties = !materialModule.IsRefractionEnabled; float surfaceLevel = waterBoundsMin.y + waterBoxHeight * materialModule.GetSurfaceLevelNormalized(); float submergeLevel = waterBoundsMin.y + waterBoxHeight * materialModule.GetSubmergeLevelNormalized(); //Finding visible Surface Area isRenderingCameraFullyContainedInWaterBox &= WaterUtility.ClipPointsAgainstAABBEdge(_clipeePoints, isBottomOrTopEdge: true, isBottomOrLeftEdge: true, edgePosition: surfaceLevel); _surfaceVisibleArea.UpdateArea(_clipeePoints, _renderingCameraFrustum, isRenderingCameraFullyContainedInWaterBox, !Reflection.RenderTextureUseFixedSize, _farClipPlane, computeRefractionProperties, isReflectionEnabled, reflectionYOffset: ReflectionYOffset, reflectionZOffset: ReflectionZOffset, reflectionAxis: waterBoundsMax.y, reflectionFrustumHeightScalingFactor: Reflection.ViewingFrustumHeightScalingFactor); //Finding visible Surface Area below submerge level isRenderingCameraFullyContainedInWaterBox &= WaterUtility.ClipPointsAgainstAABBEdge(_clipeePoints, isBottomOrTopEdge: true, isBottomOrLeftEdge: false, edgePosition: submergeLevel); _surfaceBelowSubmergeLevelVisibleArea.UpdateArea(_clipeePoints, _renderingCameraFrustum, isRenderingCameraFullyContainedInWaterBox, !ReflectionPartiallySubmergedObjects.RenderTextureUseFixedSize, _farClipPlane, false, isReflectionEnabled, reflectionYOffset: ReflectionYOffset, reflectionZOffset: ReflectionZOffset, reflectionAxis: submergeLevel, reflectionFrustumHeightScalingFactor: ReflectionPartiallySubmergedObjects.ViewingFrustumHeightScalingFactor); } }