public DynamicWater(Water water, DynamicWater.Data data) { this._Water = water; this._Data = data; DynamicWater.CreateCommandBuffers(); this.Validate(); this._MapLocalDisplacementsShader = Shader.Find("UltimateWater/Utility/Map Local Displacements"); }
private void OnDisable() { WaterRipples.Unregister(this); DynamicWater.RemoveRenderer <WaterSimulationArea>(this); this.ReleaseDepthCamera(); this.ReleaseTextures(); if (this._CommandBuffer != null) { this._CommandBuffer.Release(); this._CommandBuffer = null; } }
internal override void OnWaterRender(WaterCamera waterCamera) { Camera cameraComponent = waterCamera.CameraComponent; if (waterCamera.Type != WaterCamera.CameraType.Normal || !Application.isPlaying) { return; } if (!WaterProjectSettings.Instance.RenderInSceneView && WaterUtilities.IsSceneViewCamera(cameraComponent)) { return; } Shader.SetGlobalVector("_TileSizesInv", this._Water.WindWaves.TileSizesInv); DynamicWaterCameraData cameraOverlaysData = this.GetCameraOverlaysData(cameraComponent, true); cameraOverlaysData.SwapFoamMaps(); cameraOverlaysData.ClearOverlays(); DynamicWater.DrawDisplacementMaskRenderers(cameraOverlaysData); DynamicWater.DrawDisplacementRenderers(cameraOverlaysData); for (int i = 0; i < this._OverlayRenderers.Length; i++) { this._OverlayRenderers[i].RenderOverlays(cameraOverlaysData); } if (this._Water.Foam != null) { this._Water.Foam.RenderOverlays(cameraOverlaysData); } for (int j = 0; j < this._OverlayRenderers.Length; j++) { this._OverlayRenderers[j].RenderFoam(cameraOverlaysData); } int localDiffuseMap = ShaderVariables.LocalDiffuseMap; MaterialPropertyBlock propertyBlock = this._Water.Renderer.PropertyBlock; propertyBlock.SetTexture(ShaderVariables.LocalDisplacementMap, cameraOverlaysData.DynamicDisplacementMap); propertyBlock.SetTexture(ShaderVariables.LocalNormalMap, cameraOverlaysData.NormalMap); propertyBlock.SetTexture(ShaderVariables.TotalDisplacementMap, cameraOverlaysData.TotalDisplacementMap); propertyBlock.SetTexture(ShaderVariables.DisplacementsMask, cameraOverlaysData.DisplacementsMask); propertyBlock.SetTexture(localDiffuseMap, cameraOverlaysData.DiffuseMap); Shader.SetGlobalTexture("DIFFUSE", cameraOverlaysData.DiffuseMap); RenderTexture debugMap = cameraOverlaysData.GetDebugMap(false); if (debugMap != null) { propertyBlock.SetTexture("_LocalDebugMap", debugMap); } if (waterCamera.MainWater == this._Water) { Shader.SetGlobalTexture(ShaderVariables.TotalDisplacementMap, cameraOverlaysData.TotalDisplacementMap); } DynamicWater.DrawFoamRenderers(cameraOverlaysData); DynamicWater.DrawDiffuseRenderers(cameraOverlaysData); }
private void OnDisable() { if (this._DisplacementMaterial != null) { DynamicWater.RemoveRenderer <ILocalDisplacementRenderer>(this); } if (this._FoamMaterial != null) { DynamicWater.RemoveRenderer <ILocalFoamRenderer>(this); } if (this._RenderDiffuse) { DynamicWater.RemoveRenderer <ILocalDiffuseRenderer>(this); } }
private void OnEnable() { if (this._DisplacementAndNormalMaterial != null) { DynamicWater.AddRenderer <ILocalDisplacementRenderer>(this); } if (this._DisplacementMaskMaterial != null) { DynamicWater.AddRenderer <ILocalDisplacementMaskRenderer>(this); } if (this._FoamMaterial != null) { DynamicWater.AddRenderer <ILocalFoamRenderer>(this); } }
private void OnEnable() { this._Position = base.transform.position; this._Scale = base.transform.localScale; this._CommandBuffer = new CommandBuffer { name = "[Ultimate Water]: Water Simulation Area" }; this.CreateDepthCamera(); this.CreateTextures(); this.UpdateShaderVariables(); this.RenderStaticDepthTexture(); DynamicWater.AddRenderer <WaterSimulationArea>(this); WaterRipples.Register(this); }
public DynamicWaterCameraData GetCameraOverlaysData(Camera camera, bool createIfNotExists = true) { DynamicWaterCameraData dynamicWaterCameraData; if (!this._Buffers.TryGetValue(camera, out dynamicWaterCameraData) && createIfNotExists) { dynamicWaterCameraData = (this._Buffers[camera] = new DynamicWaterCameraData(this, WaterCamera.GetWaterCamera(camera, false), this._Data.Antialiasing)); DynamicWater.DrawDisplacementMaskRenderers(dynamicWaterCameraData); dynamicWaterCameraData.SwapFoamMaps(); for (int i = 0; i < this._OverlayRenderers.Length; i++) { this._OverlayRenderers[i].RenderOverlays(dynamicWaterCameraData); } } if (dynamicWaterCameraData != null) { dynamicWaterCameraData._LastFrameUsed = Time.frameCount; } return(dynamicWaterCameraData); }
private void OnDisable() { DynamicWater.RemoveRenderer <ILocalDisplacementRenderer>(this); DynamicWater.RemoveRenderer <ILocalDisplacementMaskRenderer>(this); DynamicWater.RemoveRenderer <ILocalFoamRenderer>(this); }
private void OnDisable() { DynamicWater.RemoveRenderer <ILocalDisplacementMaskRenderer>(this); StaticWaterInteraction.StaticWaterInteractions.Remove(this); }
private void OnEnable() { StaticWaterInteraction.StaticWaterInteractions.Add(this); DynamicWater.AddRenderer <ILocalDisplacementMaskRenderer>(this); }
private void Unregister() { DynamicWater.RemoveRenderer <WaterProjector>(this); }
private void Register() { DynamicWater.AddRenderer <WaterProjector>(this); }
private void OnDisable() { DynamicWater.RemoveRenderer <WaterInteractive>(this); }
private void OnEnable() { DynamicWater.AddRenderer <WaterInteractive>(this); }