Esempio n. 1
0
        private void OnProfilesChanged(Water water)
        {
            this._TileSize               = 0f;
            this._WindSpeedMagnitude     = 0f;
            this._SpectrumDirectionality = 0f;
            Water.WeightedProfile[] profiles = water.ProfilesManager.Profiles;
            for (int i = 0; i < profiles.Length; i++)
            {
                WaterProfileData profile = profiles[i].Profile;
                float            weight  = profiles[i].Weight;
                this._TileSize               += profile.TileSize * profile.TileScale * weight;
                this._WindSpeedMagnitude     += profile.WindSpeed * weight;
                this._SpectrumDirectionality += profile.Directionality * weight;
            }
            WaterQualitySettings instance = WaterQualitySettings.Instance;

            this._TileSize         *= instance.TileSizeScale;
            this._UnscaledTileSizes = this._TileSize * this._TileSizeScales;
            this.UpdateShaderParams();
            MaterialPropertyBlock propertyBlock = water.Renderer.PropertyBlock;

            propertyBlock.SetVector(ShaderVariables.WaterTileSizeScales, new Vector4(this._TileSizeScales.x / this._TileSizeScales.y, this._TileSizeScales.x / this._TileSizeScales.z, this._TileSizeScales.x / this._TileSizeScales.w, 0f));
            this._SpectrumResolver.OnProfilesChanged();
            propertyBlock.SetFloat(ShaderVariables.MaxDisplacement, this._SpectrumResolver.MaxHorizontalDisplacement);
        }
Esempio n. 2
0
 internal void OnProfilesChanged(Water water)
 {
     Water.WeightedProfile[] profiles = water.ProfilesManager.Profiles;
     this.Density = 0f;
     this.Gravity = 0f;
     for (int i = 0; i < profiles.Length; i++)
     {
         WaterProfileData profile = profiles[i].Profile;
         float            weight  = profiles[i].Weight;
         this.Density += profile.Density * weight;
         this.Gravity -= profile.Gravity * weight;
     }
 }
Esempio n. 3
0
 private void ResolveProfileData(Water water)
 {
     Water.WeightedProfile[] profiles = water.ProfilesManager.Profiles;
     this._ShaderParams.x = 0f;
     this._ShaderParams.y = 0f;
     for (int i = 0; i < profiles.Length; i++)
     {
         WaterProfileData profile = profiles[i].Profile;
         float            weight  = profiles[i].Weight;
         this._ShaderParams.x = this._ShaderParams.x + profile.IsotropicScatteringIntensity * weight;
         this._ShaderParams.y = this._ShaderParams.y + profile.SubsurfaceScatteringContrast * weight;
     }
     this._ShaderParams.x = this._ShaderParams.x * (1f + this._ShaderParams.y);
 }
Esempio n. 4
0
 private void OnProfilesChanged(Water water)
 {
     Water.WeightedProfile[] profiles = water.ProfilesManager.Profiles;
     this._SpawnThreshold = 0f;
     this._SpawnSkipRatio = 0f;
     this._Scale          = 0f;
     if (profiles != null)
     {
         foreach (Water.WeightedProfile weightedProfile in profiles)
         {
             WaterProfileData profile = weightedProfile.Profile;
             float            weight  = weightedProfile.Weight;
             this._SpawnThreshold += profile.SprayThreshold * weight;
             this._SpawnSkipRatio += profile.SpraySkipRatio * weight;
             this._Scale          += profile.SpraySize * weight;
         }
     }
 }
Esempio n. 5
0
        private void OnProfilesChanged(Water water)
        {
            Water.WeightedProfile[] profiles = water.ProfilesManager.Profiles;
            if (profiles == null)
            {
                return;
            }
            float num = 0f;

            for (int i = profiles.Length - 1; i >= 0; i--)
            {
                Water.WeightedProfile weightedProfile = profiles[i];
                WaterProfileData      profile         = weightedProfile.Profile;
                float weight = weightedProfile.Weight;
                num += profile.PlanarReflectionIntensity * weight;
            }
            this._RenderPlanarReflections = (num > 0f);
        }
 public void Copy(WaterProfileData other)
 {
     this._Spectrum                    = other._Spectrum;
     this._SpectrumType                = other._SpectrumType;
     this._WindSpeed                   = other._WindSpeed;
     this._TileSize                    = other._TileSize;
     this._TileScale                   = other._TileScale;
     this._WavesAmplitude              = other._WavesAmplitude;
     this._WavesFrequencyScale         = other._WavesFrequencyScale;
     this._HorizontalDisplacementScale = other._HorizontalDisplacementScale;
     this._PhillipsCutoffFactor        = other._PhillipsCutoffFactor;
     this._Gravity         = other._Gravity;
     this._Fetch           = other._Fetch;
     this._Directionality  = other._Directionality;
     this._AbsorptionColor = other._AbsorptionColor;
     this._CustomUnderwaterAbsorptionColor    = other._CustomUnderwaterAbsorptionColor;
     this._AbsorptionColorByDepth             = other._AbsorptionColorByDepth;
     this._AbsorptionColorByDepthFlatGradient = other._AbsorptionColorByDepthFlatGradient;
     this._DiffuseColor                   = other._DiffuseColor;
     this._SpecularColor                  = other._SpecularColor;
     this._DepthColor                     = other._DepthColor;
     this._EmissionColor                  = other._EmissionColor;
     this._ReflectionColor                = other._ReflectionColor;
     this._Smoothness                     = other._Smoothness;
     this._CustomAmbientSmoothness        = other._CustomAmbientSmoothness;
     this._AmbientSmoothness              = other._AmbientSmoothness;
     this._IsotropicScatteringIntensity   = other._IsotropicScatteringIntensity;
     this._ForwardScatteringIntensity     = other._ForwardScatteringIntensity;
     this._SubsurfaceScatteringContrast   = other._SubsurfaceScatteringContrast;
     this._SubsurfaceScatteringShoreColor = other._SubsurfaceScatteringShoreColor;
     this._RefractionDistortion           = other._RefractionDistortion;
     this._FresnelBias                    = other._FresnelBias;
     this._DetailFadeDistance             = other._DetailFadeDistance;
     this._DisplacementNormalsIntensity   = other._DisplacementNormalsIntensity;
     this._PlanarReflectionIntensity      = other._PlanarReflectionIntensity;
     this._PlanarReflectionFlatten        = other._PlanarReflectionFlatten;
     this._PlanarReflectionVerticalOffset = other._PlanarReflectionVerticalOffset;
     this._EdgeBlendFactor                = other._EdgeBlendFactor;
     this._DirectionalWrapSss             = other._DirectionalWrapSss;
     this._PointWrapSss                   = other._PointWrapSss;
     this._Density                            = other._Density;
     this._UnderwaterBlurSize                 = other._UnderwaterBlurSize;
     this._UnderwaterLightFadeScale           = other._UnderwaterLightFadeScale;
     this._UnderwaterDistortionsIntensity     = other._UnderwaterDistortionsIntensity;
     this._UnderwaterDistortionAnimationSpeed = other._UnderwaterDistortionAnimationSpeed;
     this._DynamicSmoothnessIntensity         = other._DynamicSmoothnessIntensity;
     this._NormalMapAnimation1                = other._NormalMapAnimation1;
     this._NormalMapAnimation2                = other._NormalMapAnimation2;
     this._NormalMap                          = other._NormalMap;
     this._FoamIntensity                      = other._FoamIntensity;
     this._FoamThreshold                      = other._FoamThreshold;
     this._FoamFadingFactor                   = other._FoamFadingFactor;
     this._FoamShoreIntensity                 = other._FoamShoreIntensity;
     this._FoamShoreExtent                    = other._FoamShoreExtent;
     this._FoamNormalScale                    = other._FoamNormalScale;
     this._FoamDiffuseColor                   = other._FoamDiffuseColor;
     this._FoamSpecularColor                  = other._FoamSpecularColor;
     this._SprayThreshold                     = other._SprayThreshold;
     this._SpraySkipRatio                     = other._SpraySkipRatio;
     this._SpraySize                          = other._SpraySize;
     this._FoamDiffuseMap                     = other._FoamDiffuseMap;
     this._FoamNormalMap                      = other._FoamNormalMap;
     this._FoamTiling                         = other._FoamTiling;
 }
Esempio n. 7
0
        private void OnProfilesChanged(Water water)
        {
            Water.WeightedProfile[] profiles = water.ProfilesManager.Profiles;
            WaterProfileData        profile  = profiles[0].Profile;
            float num = 0f;

            foreach (Water.WeightedProfile weightedProfile in profiles)
            {
                if (profile == null || num < weightedProfile.Weight)
                {
                    profile = weightedProfile.Profile;
                    num     = weightedProfile.Weight;
                }
            }
            this.HorizontalDisplacementScale        = 0f;
            this.UnderwaterBlurSize                 = 0f;
            this.UnderwaterLightFadeScale           = 0f;
            this.UnderwaterDistortionsIntensity     = 0f;
            this.UnderwaterDistortionAnimationSpeed = 0f;
            Color color  = new Color(0f, 0f, 0f, 0f);
            Color color2 = new Color(0f, 0f, 0f, 0f);
            Color color3 = new Color(0f, 0f, 0f, 0f);
            Color color4 = new Color(0f, 0f, 0f, 0f);
            Color color5 = new Color(0f, 0f, 0f, 0f);
            Color color6 = new Color(0f, 0f, 0f, 0f);
            Color color7 = new Color(0f, 0f, 0f, 0f);
            Color color8 = new Color(0f, 0f, 0f, 0f);
            Color color9 = new Color(0f, 0f, 0f, 0f);

            this._Smoothness        = 0f;
            this._AmbientSmoothness = 0f;
            float num2 = 0f;
            float num3 = 0f;
            float num4 = 0f;
            float num5 = 0f;
            float num6 = 0f;
            float num7 = 0f;

            this._ForwardScatteringIntensity = 0f;
            Vector3            v = default(Vector3);
            Vector2            a = default(Vector2);
            NormalMapAnimation normalMapAnimation  = default(NormalMapAnimation);
            NormalMapAnimation normalMapAnimation2 = default(NormalMapAnimation);

            for (int j = 0; j < profiles.Length; j++)
            {
                WaterProfileData profile2 = profiles[j].Profile;
                float            weight   = profiles[j].Weight;
                this.HorizontalDisplacementScale        += profile2.HorizontalDisplacementScale * weight;
                this.UnderwaterBlurSize                 += profile2.UnderwaterBlurSize * weight;
                this.UnderwaterLightFadeScale           += profile2.UnderwaterLightFadeScale * weight;
                this.UnderwaterDistortionsIntensity     += profile2.UnderwaterDistortionsIntensity * weight;
                this.UnderwaterDistortionAnimationSpeed += profile2.UnderwaterDistortionAnimationSpeed * weight;
                color                   += profile2.AbsorptionColor * weight;
                color2                  += profile2.DiffuseColor * weight;
                color3                  += profile2.SpecularColor * weight;
                color4                  += profile2.DepthColor * weight;
                color5                  += profile2.EmissionColor * weight;
                color6                  += profile2.ReflectionColor * weight;
                color7                  += profile2.FoamDiffuseColor * weight;
                color8                  += profile2.FoamSpecularColor * weight;
                this._Smoothness        += profile2.Smoothness * weight;
                this._AmbientSmoothness += profile2.AmbientSmoothness * weight;
                num2   += profile2.RefractionDistortion * weight;
                color9 += profile2.SubsurfaceScatteringShoreColor * weight;
                num3   += profile2.DetailFadeDistance * weight;
                num4   += profile2.DisplacementNormalsIntensity * weight;
                num5   += profile2.EdgeBlendFactor * weight;
                num6   += profile2.DirectionalWrapSSS * weight;
                num7   += profile2.PointWrapSSS * weight;
                this._ForwardScatteringIntensity += profile2.ForwardScatteringIntensity * weight;
                v.x += profile2.PlanarReflectionIntensity * weight;
                v.y += profile2.PlanarReflectionFlatten * weight;
                v.z += profile2.PlanarReflectionVerticalOffset * weight;
                a   += profile2.FoamTiling * weight;
                normalMapAnimation  += profile2.NormalMapAnimation1 * weight;
                normalMapAnimation2 += profile2.NormalMapAnimation2 * weight;
            }
            if (water.WindWaves != null && water.WindWaves.FinalRenderMode == WaveSpectrumRenderMode.GerstnerAndFFTNormals)
            {
                num4 *= 0.5f;
            }
            MaterialPropertyBlock propertyBlock = water.Renderer.PropertyBlock;

            color9.a = this._ForwardScatteringIntensity;
            propertyBlock.SetVector(WaterMaterials._ParameterHashes[0], color);
            propertyBlock.SetColor(WaterMaterials._ParameterHashes[1], color2);
            propertyBlock.SetColor(WaterMaterials._ParameterHashes[2], color3);
            propertyBlock.SetColor(WaterMaterials._ParameterHashes[3], color4);
            propertyBlock.SetColor(WaterMaterials._ParameterHashes[4], color5);
            propertyBlock.SetColor(WaterMaterials._ParameterHashes[5], color6);
            propertyBlock.SetColor(WaterMaterials._ParameterHashes[24], color7);
            propertyBlock.SetColor(WaterMaterials._ParameterHashes[22], color8);
            propertyBlock.SetFloat(WaterMaterials._ParameterHashes[6], this.HorizontalDisplacementScale);
            propertyBlock.SetFloat(WaterMaterials._ParameterHashes[7], this._AmbientSmoothness);
            propertyBlock.SetVector(WaterMaterials._ParameterHashes[9], new Vector4(num6, 1f / (1f + num6), num7, 1f / (1f + num7)));
            propertyBlock.SetFloat(WaterMaterials._ParameterHashes[10], num2);
            propertyBlock.SetColor(WaterMaterials._ParameterHashes[11], color9);
            propertyBlock.SetFloat(WaterMaterials._ParameterHashes[12], 1f / num3);
            propertyBlock.SetFloat(WaterMaterials._ParameterHashes[13], num4);
            propertyBlock.SetFloat(WaterMaterials._ParameterHashes[14], 1f / num5);
            propertyBlock.SetVector(WaterMaterials._ParameterHashes[15], v);
            propertyBlock.SetVector(WaterMaterials._ParameterHashes[16], new Vector4(normalMapAnimation.Intensity, normalMapAnimation2.Intensity, -(normalMapAnimation.Intensity + normalMapAnimation2.Intensity) * 0.5f, 0f));
            propertyBlock.SetVector(WaterMaterials._ParameterHashes[17], new Vector2(a.x / normalMapAnimation.Tiling.x, a.y / normalMapAnimation.Tiling.y));
            propertyBlock.SetFloat(WaterMaterials._ParameterHashes[18], this._Smoothness / this._AmbientSmoothness);
            this.SurfaceMaterial.SetTexture(WaterMaterials._ParameterHashes[19], profile.NormalMap);
            this.SurfaceMaterial.SetTexture(WaterMaterials._ParameterHashes[20], profile.FoamDiffuseMap);
            this.SurfaceMaterial.SetTexture(WaterMaterials._ParameterHashes[21], profile.FoamNormalMap);
            water.UVAnimator.NormalMapAnimation1 = normalMapAnimation;
            water.UVAnimator.NormalMapAnimation2 = normalMapAnimation2;
            if (this._VectorOverrides != null)
            {
                this.ApplyOverridenParameters();
            }
            this._AbsorptionGradientDirty = true;
            this.UpdateSurfaceBackMaterial();
            this.UpdateVolumeMaterials();
            this.UpdateGlobalLookupTex();
        }