private void BuildShaderVariant(ShaderVariant variant, WaterQualityLevel qualityLevel) { bool flag = this._TransparencyMode == WaterTransparencyMode.Refractive && qualityLevel.AllowAlphaBlending; variant.SetWaterKeyword("_WATER_REFRACTION", flag); variant.SetWaterKeyword("_CUBEMAP_REFLECTIONS", this._ReflectionProbeUsage != ReflectionProbeUsage.Off); variant.SetWaterKeyword("_WATER_RECEIVE_SHADOWS", this._ReceiveShadows); variant.SetWaterKeyword("_ALPHABLEND_ON", flag); variant.SetWaterKeyword("_ALPHAPREMULTIPLY_ON", !flag); variant.SetUnityKeyword("_TRIANGLES", this._CustomTriangularGeometry); if (this._ProjectionGrid) { variant.SetAdditionalSurfaceCode("_PROJECTION_GRID", "\t\t\t#pragma multi_compile _PROJECTION_GRID_OFF _PROJECTION_GRID"); } variant.SetUnityKeyword("_WATER_OVERLAYS", this._LocalEffectsSupported); variant.SetUnityKeyword("_LOCAL_MAPS_DEBUG", this._LocalEffectsSupported && this._LocalEffectsDebug); WindWavesRenderMode windWavesRenderMode = this.BuildWindWavesVariant(variant, qualityLevel); variant.SetWaterKeyword("_WATER_FOAM_WS", this._Foam && !this._LocalEffectsSupported && windWavesRenderMode == WindWavesRenderMode.FullFFT); variant.SetUnityKeyword("_BOUNDED_WATER", this._DisplayOnlyInAdditiveVolumes); variant.SetUnityKeyword("_WAVES_ALIGN", this._WavesAlign); variant.SetWaterKeyword("_NORMALMAP", this._NormalMappingMode == NormalMappingMode.Always || (this._NormalMappingMode == NormalMappingMode.Auto && windWavesRenderMode > WindWavesRenderMode.GerstnerAndFFTNormals)); variant.SetWaterKeyword("_EMISSION", this._SupportEmission); variant.SetWaterKeyword("_PLANAR_REFLECTIONS", this._PlanarReflections == PlanarReflectionsMode.Normal); variant.SetWaterKeyword("_PLANAR_REFLECTIONS_HQ", this._PlanarReflections == PlanarReflectionsMode.HighQuality); }
private WindWavesRenderMode BuildWindWavesVariant(ShaderVariant variant, WaterQualityLevel qualityLevel) { WaterWavesMode wavesMode = qualityLevel.WavesMode; WindWavesRenderMode windWavesRenderMode; if (this._WindWavesMode == WindWavesRenderMode.Disabled || wavesMode == WaterWavesMode.DisallowAll) { windWavesRenderMode = WindWavesRenderMode.Disabled; } else if (this._WindWavesMode == WindWavesRenderMode.FullFFT && wavesMode == WaterWavesMode.AllowAll) { windWavesRenderMode = WindWavesRenderMode.FullFFT; } else if (this._WindWavesMode <= WindWavesRenderMode.GerstnerAndFFTNormals && wavesMode <= WaterWavesMode.AllowNormalFFT) { windWavesRenderMode = WindWavesRenderMode.GerstnerAndFFTNormals; } else { windWavesRenderMode = WindWavesRenderMode.Gerstner; } if (windWavesRenderMode != WindWavesRenderMode.FullFFT) { if (windWavesRenderMode != WindWavesRenderMode.GerstnerAndFFTNormals) { if (windWavesRenderMode == WindWavesRenderMode.Gerstner) { variant.SetUnityKeyword("_WAVES_GERSTNER", true); } } else { variant.SetWaterKeyword("_WAVES_FFT_NORMAL", true); variant.SetUnityKeyword("_WAVES_GERSTNER", true); } } else { variant.SetUnityKeyword("_WAVES_FFT", true); } if (this._DynamicSmoothnessMode == DynamicSmoothnessMode.Physical) { variant.SetWaterKeyword("_INCLUDE_SLOPE_VARIANCE", true); } return(windWavesRenderMode); }