예제 #1
0
        internal void UpdateShaderVariables()
        {
            if (this.Profile == null)
            {
                return;
            }
            if (this._DisplacementMaterial.IsNullReference(this))
            {
                return;
            }
            float num = (float)this._PixelsPerUnit / 32f;

            RipplesShader.SetPropagation(this.Profile.Propagation * num, this._RipplesMaterial);
            RipplesShader.SetStaticDepth(DefaultTextures.Get(Color.clear), this._RipplesMaterial);
            RipplesShader.SetDamping(this.Profile.Damping / 32f, this._RipplesMaterial);
            RipplesShader.SetGain(this.Profile.Gain, this._RipplesMaterial);
            RipplesShader.SetHeightGain(this.Profile.HeightGain, this._RipplesMaterial);
            RipplesShader.SetHeightOffset(this.Profile.HeightOffset, this._RipplesMaterial);
            float[] array = UltimateWater.Utils.Math.GaussianTerms(this.Profile.Sigma);
            GaussianShader.Term0 = array[0];
            GaussianShader.Term1 = array[1];
            GaussianShader.Term2 = array[2];
            this._DisplacementMaterial.SetFloat("_Amplitude", this.Profile.Amplitude * 0.05f);
            this._DisplacementMaterial.SetFloat("_Spread", this.Profile.Spread);
            this._DisplacementMaterial.SetFloat("_Multiplier", this.Profile.Multiplier);
            this._DisplacementMaterial.SetFloat("_Fadeout", (!this._Fade) ? 0f : 1f);
            this._DisplacementMaterial.SetFloat("_FadePower", this._FadePower);
        }
예제 #2
0
        private void RenderStaticDepthTexture()
        {
            if (!this._EnableStaticCalculations)
            {
                if (this._StaticDepth != null)
                {
                    this._StaticDepth.Release();
                    this._StaticDepth = null;
                }
                return;
            }
            if (this._DepthCamera.IsNullReference(this))
            {
                return;
            }
            if (this._StaticDepth == null)
            {
                TextureUtility.RenderTextureDesc desc = new TextureUtility.RenderTextureDesc("[UWS] - Static Depth")
                {
                    Width  = this._StaticWidth,
                    Height = this._StaticHeight,
                    Depth  = 24,
                    Format = RenderTextureFormat.RFloat,
                    Filter = FilterMode.Point
                };
                this._StaticDepth = desc.CreateRenderTexture();
                this._StaticDepth.Clear(Color.clear, false, true);
            }
            float y             = this._DepthCamera.transform.localPosition.y;
            float nearClipPlane = this._DepthCamera.nearClipPlane;
            float farClipPlane  = this._DepthCamera.farClipPlane;

            WaterSimulationArea.SetDepthCameraParameters(ref this._DepthCamera, 40f, 0f, 80f);
            this._DepthCamera.cullingMask   = WaterQualitySettings.Instance.Ripples.StaticDepthMask;
            this._DepthCamera.targetTexture = this._StaticDepth;
            this._DepthCamera.SetReplacementShader(ShaderUtility.Instance.Get(ShaderList.Depth), string.Empty);
            this._DepthCamera.Render();
            WaterSimulationArea.SetDepthCameraParameters(ref this._DepthCamera, y, nearClipPlane, farClipPlane);
            RipplesShader.SetStaticDepth(this._StaticDepth, this._RipplesMaterial);
        }