Example #1
0
        private void CreateDepthCamera()
        {
            if (this.Resolution.x <= 0f || this.Resolution.y <= 0f)
            {
                Debug.LogError("WaterSimulationArea: invalid resolution");
            }
            GameObject gameObject = new GameObject("Depth");

            gameObject.transform.SetParent(base.transform);
            this._DepthCamera                         = gameObject.AddComponent <Camera>();
            this._DepthCamera.enabled                 = false;
            this._DepthCamera.backgroundColor         = Color.clear;
            this._DepthCamera.clearFlags              = CameraClearFlags.Color;
            this._DepthCamera.orthographic            = true;
            this._DepthCamera.orthographicSize        = this.Size.y * 0.5f;
            this._DepthCamera.aspect                  = this.Resolution.x / this.Resolution.y;
            this._DepthCamera.transform.localRotation = Quaternion.Euler(new Vector3(90f, 180f, 0f));
            this._DepthCamera.transform.localScale    = Vector3.one;
            this._DepthCamera.depthTextureMode        = DepthTextureMode.Depth;
            WaterSimulationArea.SetDepthCameraParameters(ref this._DepthCamera, 10f, 0f, 20f);
        }
Example #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);
        }