Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        internal void ResolveFinalSettings(WaterQualityLevel quality)
        {
            this.CreateObjects();
            WaterWavesMode wavesMode = quality.WavesMode;

            if (wavesMode == WaterWavesMode.DisallowAll)
            {
                this._WaterWavesFFT.Disable();
                this._WaterWavesGerstner.Disable();
                return;
            }
            bool flag = SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.ARGBFloat) || SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.ARGBHalf);
            int  num  = Mathf.Min(new int[]
            {
                this._Data.Resolution,
                quality.MaxSpectrumResolution,
                SystemInfo.maxTextureSize
            });
            bool flag2 = this._Data.HighPrecision && quality.AllowHighPrecisionTextures && SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.ARGBFloat);
            WindWavesRenderMode windWavesMode = this._Water.ShaderSet.WindWavesMode;

            if (windWavesMode == WindWavesRenderMode.FullFFT && wavesMode == WaterWavesMode.AllowAll && flag)
            {
                this._FinalRenderMode = WaveSpectrumRenderMode.FullFFT;
            }
            else if (windWavesMode <= WindWavesRenderMode.GerstnerAndFFTNormals && wavesMode <= WaterWavesMode.AllowNormalFFT && flag)
            {
                this._FinalRenderMode = WaveSpectrumRenderMode.GerstnerAndFFTNormals;
            }
            else
            {
                this._FinalRenderMode = WaveSpectrumRenderMode.Gerstner;
            }
            if (this._FinalResolution != num)
            {
                lock (this)
                {
                    this._FinalResolution    = num;
                    this._FinalHighPrecision = flag2;
                    if (this._SpectrumResolver != null)
                    {
                        this._SpectrumResolver.OnMapsFormatChanged(true);
                    }
                    if (this.ResolutionChanged != null)
                    {
                        this.ResolutionChanged.Invoke(this);
                    }
                }
            }
            else if (this._FinalHighPrecision != flag2)
            {
                lock (this)
                {
                    this._FinalHighPrecision = flag2;
                    if (this._SpectrumResolver != null)
                    {
                        this._SpectrumResolver.OnMapsFormatChanged(false);
                    }
                }
            }
            WaveSpectrumRenderMode finalRenderMode = this._FinalRenderMode;

            if (finalRenderMode != WaveSpectrumRenderMode.FullFFT)
            {
                if (finalRenderMode != WaveSpectrumRenderMode.GerstnerAndFFTNormals)
                {
                    if (finalRenderMode == WaveSpectrumRenderMode.Gerstner)
                    {
                        this._WaterWavesFFT.Disable();
                        this._WaterWavesGerstner.Enable();
                    }
                }
                else
                {
                    this._WaterWavesFFT.RenderedMaps = WavesRendererFFT.MapType.Normal;
                    this._WaterWavesFFT.Enable();
                    this._WaterWavesGerstner.Enable();
                }
            }
            else
            {
                this._WaterWavesFFT.RenderedMaps = (WavesRendererFFT.MapType.Displacement | WavesRendererFFT.MapType.Normal);
                this._WaterWavesFFT.Enable();
                this._WaterWavesGerstner.Disable();
            }
        }