public void BuildShaderVariant(ShaderVariant variant, Water water, WaterQualityLevel qualityLevel) { CreateObjects(); ResolveFinalSettings(qualityLevel); waterWavesFFT.BuildShaderVariant(variant, water, this, qualityLevel); waterWavesGerstner.BuildShaderVariant(variant, water, this, qualityLevel); variant.SetWaterKeyword("_INCLUDE_SLOPE_VARIANCE", dynamicSmoothness.Enabled); }
public void SetQualityLevel(int index) { if (!Application.isPlaying) { savedCustomQualityLevel = index; } currentQualityLevel = qualityLevels[index]; waterQualityIndex = index; OnChange(); }
internal void ResolveFinalSettings(WaterQualityLevel qualityLevel) { finalHighQualitySlopeMaps = highQualitySlopeMaps; if (!qualityLevel.allowHighQualitySlopeMaps) { finalHighQualitySlopeMaps = false; } if ((renderedMaps & MapType.Displacement) == 0) // if heightmap is not rendered, only high-quality slope map is possible { finalHighQualitySlopeMaps = true; } }
public void BuildShaderVariant(ShaderVariant variant, Water water, WindWaves windWaves, WaterQualityLevel qualityLevel) { variant.SetUnityKeyword("_WAVES_GERSTNER", enabled); }
public void UpdateMaterial(Water water, WaterQualityLevel qualityLevel) { }
/// <summary> /// Resolves final component settings based on the desired values, quality settings and hardware limitations. /// </summary> internal void ResolveFinalSettings(WaterQualityLevel quality) { CreateObjects(); var wavesMode = quality.wavesMode; if (wavesMode == WaterWavesMode.DisallowAll) { enabled = false; return; } bool supportsFloats = SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.ARGBFloat) || SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.ARGBHalf); int finalResolution = Mathf.Min(resolution, quality.maxSpectrumResolution, SystemInfo.maxTextureSize); bool finalHighPrecision = highPrecision && quality.allowHighPrecisionTextures && SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.ARGBFloat); if (renderMode == WaveSpectrumRenderMode.FullFFT && wavesMode == WaterWavesMode.AllowAll && supportsFloats) { finalRenderMode = WaveSpectrumRenderMode.FullFFT; } else if (renderMode <= WaveSpectrumRenderMode.GerstnerAndFFTSlope && wavesMode <= WaterWavesMode.AllowSlopeFFT && supportsFloats) { finalRenderMode = WaveSpectrumRenderMode.GerstnerAndFFTSlope; } else { finalRenderMode = WaveSpectrumRenderMode.Gerstner; } if (this.finalResolution != finalResolution) { lock (this) { this.finalResolution = finalResolution; this.finalHighPrecision = finalHighPrecision; if (spectrumResolver != null) { spectrumResolver.OnMapsFormatChanged(true); } if (ResolutionChanged != null) { ResolutionChanged.Invoke(this); } } } else if (this.finalHighPrecision != finalHighPrecision) { lock (this) { this.finalHighPrecision = finalHighPrecision; if (spectrumResolver != null) { spectrumResolver.OnMapsFormatChanged(false); } } } switch (finalRenderMode) { case WaveSpectrumRenderMode.FullFFT: { waterWavesFFT.RenderedMaps = WavesRendererFFT.MapType.Displacement | WavesRendererFFT.MapType.Slope; waterWavesFFT.Enable(this); waterWavesGerstner.Disable(); break; } case WaveSpectrumRenderMode.GerstnerAndFFTSlope: { waterWavesFFT.RenderedMaps = WavesRendererFFT.MapType.Slope; waterWavesFFT.Enable(this); waterWavesGerstner.Enable(this); break; } case WaveSpectrumRenderMode.Gerstner: { waterWavesFFT.Disable(); waterWavesGerstner.Enable(this); break; } } }
public void BuildShaderVariant(ShaderVariant variant, Water water, WaterQualityLevel qualityLevel) { OnValidate(); variant.SetWaterKeyword("_WATER_FOAM_WS", enabled && overlays == null && CheckPreresquisites()); }
/// <summary> /// Ensures that water quality settings are named the same way that Unity ones. /// </summary> private void SynchronizeLevelNames() { #if UNITY_EDITOR if (qualityLevels == null) { qualityLevels = new WaterQualityLevel[0]; } string[] unityNames = QualitySettings.names; var currentNames = Names; int index = 0; bool noChanges = true; foreach (var name in currentNames) { if (unityNames[index] != name) { noChanges = false; break; } } if (noChanges) { return; } var matches = new List <WaterQualityLevel>(); var availableLevels = new List <WaterQualityLevel>(qualityLevels); var availableUnityLevels = new List <string>(unityNames); // keep existing levels with matching names for (int i = 0; i < availableLevels.Count; ++i) { var level = availableLevels[i]; if (availableUnityLevels.Contains(level.name)) { matches.Add(level); availableLevels.RemoveAt(i--); availableUnityLevels.Remove(level.name); } } // use non-matched levels as-is // possibly just their name or order has changed while (availableLevels.Count > 0 && availableUnityLevels.Count > 0) { var level = availableLevels[0]; level.name = availableUnityLevels[0]; matches.Add(level); availableLevels.RemoveAt(0); availableUnityLevels.RemoveAt(0); } // create new levels if there is more of them left while (availableUnityLevels.Count > 0) { var level = new WaterQualityLevel(); level.ResetToDefaults(); level.name = availableUnityLevels[0]; matches.Add(level); availableUnityLevels.RemoveAt(0); } // create new list with the same order as in Unity qualityLevels = new WaterQualityLevel[unityNames.Length]; for (int i = 0; i < qualityLevels.Length; ++i) { qualityLevels[i] = matches.Find(l => l.name == unityNames[i]); } UnityEditor.EditorUtility.SetDirty(this); #endif }
public void BuildShaderVariant(ShaderVariant variant, Water water, WaterQualityLevel qualityLevel) { variant.SetWaterKeyword("_PLANAR_REFLECTIONS", enabled && (!highQuality || !qualityLevel.allowHighQualityReflections)); variant.SetWaterKeyword("_PLANAR_REFLECTIONS_HQ", enabled && highQuality && qualityLevel.allowHighQualityReflections); }
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 void BuildShaderVariant(ShaderVariant variant, Water water, WaterQualityLevel qualityLevel) { variant.SetWaterKeyword("_WATER_OVERLAYS", enabled); }