internal void OnValidate(WindWaves windWaves) { if (fftShader == null) { fftShader = Shader.Find("PlayWay Water/Base/FFT"); } if (fftUtilitiesShader == null) { fftUtilitiesShader = Shader.Find("PlayWay Water/Utilities/FFT Utilities"); } #if UNITY_EDITOR if (dx11FFT == null) { var guids = UnityEditor.AssetDatabase.FindAssets("\"DX11 FFT\" t:ComputeShader"); if (guids.Length != 0) { string path = UnityEditor.AssetDatabase.GUIDToAssetPath(guids[0]); dx11FFT = (ComputeShader)UnityEditor.AssetDatabase.LoadAssetAtPath(path, typeof(ComputeShader)); UnityEditor.EditorUtility.SetDirty(windWaves); } } #endif if (Application.isPlaying && enabled) { ResolveFinalSettings(WaterQualitySettings.Instance.CurrentQualityLevel); } }
void Awake() { windWaves = wavesParticleSystem.GetComponent <WindWaves>(); OnValidate(); wavesParticleSystem.RegisterPlugin(this); }
internal void OnValidate(WindWaves windWaves) { if (enabled) { FindBestWaves(); } }
public void Start(WindWaves windWaves) { this.windWaves = windWaves; this.supported = CheckSupport(); OnCopyModeChanged(); OnValidate(windWaves); }
public void Start(Water water) { this.water = water; this.windWaves = water.GetComponent <WindWaves>(); this.hasWindWaves = windWaves != null; bumpMapST = Shader.PropertyToID("_BumpMap_ST"); detailAlbedoMapST = Shader.PropertyToID("_DetailAlbedoMap_ST"); }
private void OnResolutionChanged(WindWaves windWaves) { if (blankOutput != null) { Destroy(blankOutput); blankOutput = null; } resourcesReady = false; }
public void BuildShaderVariant(ShaderVariant variant, Water water, WindWaves windWaves, WaterQualityLevel qualityLevel) { OnValidate(windWaves); ResolveFinalSettings(qualityLevel); variant.SetWaterKeyword("_WAVES_FFT_SLOPE", enabled && renderedMaps == MapType.Slope); variant.SetUnityKeyword("_WAVES_ALIGN", (!water.Volume.Boundless && water.Volume.HasRenderableAdditiveVolumes && flattenMode == FlattenMode.Auto) || flattenMode == FlattenMode.ForcedOn); variant.SetUnityKeyword("_WAVES_FFT", enabled && (renderedMaps & MapType.Displacement) != 0); }
public SpectrumResolver(WindWaves windWaves, Shader spectrumShader) : base(windWaves, 4) { this.water = windWaves.GetComponent <Water>(); this.windWaves = windWaves; renderTimeId = Shader.PropertyToID("_RenderTime"); animationMaterial = new Material(spectrumShader); animationMaterial.hideFlags = HideFlags.DontSave; animationMaterial.SetFloat(renderTimeId, Time.time); }
void Start() { water = GetComponent <Water>(); windWaves = GetComponent <WindWaves>(); windWaves.ResolutionChanged.AddListener(OnResolutionChanged); overlays = GetComponent <WaterOverlays>(); supported = CheckSupport(); if (!supported) { enabled = false; return; } }
internal void OnValidate(WindWaves windWaves) { #if UNITY_EDITOR if (varianceShader == null) { var guids = UnityEditor.AssetDatabase.FindAssets("\"Spectral Variances\" t:ComputeShader"); if (guids.Length != 0) { string path = UnityEditor.AssetDatabase.GUIDToAssetPath(guids[0]); varianceShader = (ComputeShader)UnityEditor.AssetDatabase.LoadAssetAtPath(path, typeof(ComputeShader)); UnityEditor.EditorUtility.SetDirty(windWaves); } } #endif }
public SpectrumResolverCPU(WindWaves windWaves, int numScales) { this.water = windWaves.GetComponent <Water>(); this.windWaves = windWaves; this.spectraDataCache = new Dictionary <WaterWavesSpectrum, WaterWavesSpectrumData>(); this.spectraDataList = new List <WaterWavesSpectrumData>(); this.filteredCpuWaves = new WaterWave[0]; this.numTiles = numScales; this.cachedSeed = windWaves.GetComponent <Water>().Seed; if (fftComputationCosts == null) { PrecomputeFFTCosts(); } CreateSpectraLevels(); }
void Awake() { runtimeCopyFrom = copyFrom; tileSizeId = Shader.PropertyToID("_WaterTileSize"); tileSizeScalesId = Shader.PropertyToID("_WaterTileSizeScales"); maxDisplacementId = Shader.PropertyToID("_MaxDisplacement"); CheckSupport(); if (!initialized) { Initialize(); } ResolveFinalSettings(WaterQualitySettings.Instance.CurrentQualityLevel); }
internal void Enable(WindWaves windWaves) { if (enabled) { return; } enabled = true; this.water = windWaves.GetComponent <Water>(); this.windWaves = windWaves; if (Application.isPlaying) { water.ProfilesChanged.AddListener(OnProfilesChanged); FindBestWaves(); } }
public void OnCopyModeChanged() { copyModeDirty = true; if (lastCopyFrom != null) { lastCopyFrom.WaterWavesFFT.ResourcesChanged -= ValidateResources; } if (windWaves.CopyFrom != null) { windWaves.CopyFrom.WaterWavesFFT.ResourcesChanged += ValidateResources; } lastCopyFrom = windWaves.CopyFrom; Dispose(false); }
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>(); }
private void ValidateVarianceTextures(WindWaves windWaves) { if (varianceTexture == null) { varianceTexture = CreateVarianceTexture(RenderTextureFormat.RGHalf); } if (!varianceTexture.IsCreated()) { varianceTexture.Create(); var water = windWaves.GetComponent <Water>(); water.WaterMaterial.SetTexture("_SlopeVariance", varianceTexture); varianceShader.SetTexture(0, "_Variance", varianceTexture); lastResetIndex = 0; currentIndex = 0; } }
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; }
internal void Enable(WindWaves windWaves) { if (enabled) { return; } if (dx11FFT != null) { defaultDx11Fft = dx11FFT; } else { dx11FFT = defaultDx11Fft; } enabled = true; this.water = windWaves.GetComponent <Water>(); this.windWaves = windWaves; OnCopyModeChanged(); if (Application.isPlaying) { if (lastCopyFrom == null) { ValidateResources(); } windWaves.ResolutionChanged.AddListener(OnResolutionChanged); } OnValidate(windWaves); water.InvalidateMaterialKeywords(); fftUtilitiesMaterial = new Material(fftUtilitiesShader); fftUtilitiesMaterial.hideFlags = HideFlags.DontSave; }
private void OnResolutionChanged(WindWaves windWaves) { resolution = Mathf.RoundToInt(windWaves.FinalResolution * supersampling); Dispose(false); }
public void BuildShaderVariant(ShaderVariant variant, Water water, WindWaves windWaves, WaterQualityLevel qualityLevel) { variant.SetUnityKeyword("_WAVES_GERSTNER", enabled); }
public WaterWavesSpectrumData(Water water, WaterWavesSpectrum spectrum) { this.water = water; this.windWaves = water.GetComponent <WindWaves>(); this.spectrum = spectrum; }
private void OnResolutionChanged(WindWaves windWaves) { Dispose(false); ValidateResources(); }
private void OnWindDirectionChanged(WindWaves windWaves) { ResetComputations(); }
public WaterTileSpectrum(WindWaves windWaves, int index) { this.windWaves = windWaves; this.water = windWaves.GetComponent <Water>(); this.tileIndex = index; }