Ejemplo n.º 1
0
        private void DrawReflectionRenderTexture(Camera cam)
        {
            Vector3 rhs = this._reflectionPlanePosition;
            Vector3 up  = base.transform.up;

            this.CreateObjects(cam, ref this._reflectionRenderTex, ref _reflectionCamera);
            _reflectionCamera.CopyFrom(cam);
            float     w        = -Vector3.Dot(up, rhs);
            Vector4   plane    = new Vector4(up.x, up.y, up.z, w);
            Matrix4x4 matrixx  = ReflectionTool.CalculateReflectionMatrix(Matrix4x4.zero, plane);
            Vector3   position = cam.transform.position;
            Vector3   vector5  = matrixx.MultiplyPoint(position);

            _reflectionCamera.worldToCameraMatrix = cam.worldToCameraMatrix * matrixx;
            Vector4   clipPlane = ReflectionTool.CameraSpacePlane(_reflectionCamera, rhs, up, 1f, this.reflectClipPlaneOffset);
            Matrix4x4 matrixx2  = ReflectionTool.CalculateObliqueMatrix(cam.projectionMatrix, clipPlane, -1f);

            _reflectionCamera.projectionMatrix = matrixx2;
            _reflectionCamera.cullingMask      = -17 & this.layers.value;
            _reflectionCamera.targetTexture    = (RenderTexture)this._reflectionRenderTex;
            this._oldInvertCulling             = GL.invertCulling;
            GL.invertCulling = true;
            _reflectionCamera.transform.position = vector5;
            Vector3 eulerAngles = cam.transform.eulerAngles;

            _reflectionCamera.transform.eulerAngles = new Vector3(0f, eulerAngles.y, eulerAngles.z);
            _reflectionCamera.Render();
            _reflectionCamera.transform.position = position;
            GL.invertCulling = this._oldInvertCulling;
        }
Ejemplo n.º 2
0
        private void ApplyHexBlur()
        {
            if (this._hexBlurMat == null)
            {
                this._hexBlurMat = new Material(this.hexBlurShader);
            }
            RenderTextureWrapper wrapper = GraphicsUtils.GetRenderTexture(this._reflectionRenderTex.width, this._reflectionRenderTex.height, 0, this.bufferFormat);

            ReflectionTool.ApplyHexBlur(this._hexBlurMat, (RenderTexture)this._reflectionRenderTex, (RenderTexture)wrapper, this.hexBlurFactor, 0f, 0.5f, 1);
            ReflectionTool.ApplyHexBlur(this._hexBlurMat, (RenderTexture)wrapper, (RenderTexture)this._reflectionRenderTex, this.hexBlurFactor, 0f, 0.5f, 1);
            GraphicsUtils.ReleaseRenderTexture(wrapper);
        }