void Start() { water = GetComponent <Water>(); windWaves = GetComponent <WindWaves>(); windWaves.ResolutionChanged.AddListener(OnResolutionChanged); overlays = GetComponent <WaterOverlays>(); supported = CheckSupport(); if (!supported) { enabled = false; return; } }
void OnValidate() { if (globalFoamSimulationShader == null) { globalFoamSimulationShader = Shader.Find("PlayWay Water/Foam/Global"); } if (localFoamSimulationShader == null) { localFoamSimulationShader = Shader.Find("PlayWay Water/Foam/Local"); } supersampling = Mathf.ClosestPowerOfTwo(Mathf.RoundToInt(supersampling * 4096)) / 4096.0f; water = GetComponent <Water>(); windWaves = GetComponent <WindWaves>(); overlays = GetComponent <WaterOverlays>(); }
public WaterOverlaysData(WaterOverlays waveOverlays, WaterCamera camera, int resolution, int antialiasing) { this.waveOverlays = waveOverlays; this.camera = camera; this.initialization = true; dynamicDisplacementMap = CreateOverlayRT("Water Overlay: Displacement", RenderTextureFormat.ARGBHalf, resolution, antialiasing); slopeMapA = CreateOverlayRT("Water Overlay: Slope A", RenderTextureFormat.ARGBHalf, resolution, antialiasing); slopeMapB = CreateOverlayRT("Water Overlay: Slope B", RenderTextureFormat.ARGBHalf, resolution, antialiasing); totalDisplacementMap = CreateOverlayRT("Water Overlay: Total Displacement", RenderTextureFormat.ARGBHalf, resolution, antialiasing); if (waveOverlays.GetComponent <WaterSpray>() != null) { utilityMap = CreateOverlayRT("Water Overlay: Utility Map", RenderTextureFormat.RGHalf, resolution, antialiasing); } Graphics.SetRenderTarget(slopeMapA); GL.Clear(false, true, new Color(0.0f, 0.0f, 0.0f, 1.0f)); Graphics.SetRenderTarget(null); }
void Start() { water = GetComponent <Water>(); windWaves = GetComponent <WindWaves>(); overlays = GetComponent <WaterOverlays>(); foamParametersId = Shader.PropertyToID("_FoamParameters"); foamIntensityId = Shader.PropertyToID("_FoamIntensity"); windWaves.ResolutionChanged.AddListener(OnResolutionChanged); resolution = Mathf.RoundToInt(windWaves.FinalResolution * supersampling); globalFoamSimulationMaterial = new Material(globalFoamSimulationShader); globalFoamSimulationMaterial.hideFlags = HideFlags.DontSave; localFoamSimulationMaterial = new Material(localFoamSimulationShader); localFoamSimulationMaterial.hideFlags = HideFlags.DontSave; firstFrame = true; }
void OnDisable() { WaterOverlays.UnregisterInteraction(this); staticWaterInteractions.Remove(this); }
void OnEnable() { staticWaterInteractions.Add(this); WaterOverlays.RegisterInteraction(this); }