示例#1
0
        protected virtual void SetProjectionMatrix()
        {
            var h = (float)(GetHeight() - GroundHeight);

            CameraComponent.nearClipPlane = Mathf.Clamp(0.1f * h, 0.03f, 1000.0f);
            CameraComponent.farClipPlane  = Mathf.Clamp(1e6f * h, 1000.0f, 1e12f);

            CameraComponent.ResetProjectionMatrix();

            var projectionMatrix = CameraComponent.projectionMatrix;

            if (SystemInfo.graphicsDeviceVersion.IndexOf("Direct3D") > -1)
            {
                // NOTE : Default unity antialiasing breaks matrices?
                if (CameraHelper.IsDeferred(CameraComponent) || QualitySettings.antiAliasing == 0)
                {
                    // Invert Y for rendering to a render texture
                    for (byte i = 0; i < 4; i++)
                    {
                        projectionMatrix[1, i] = -projectionMatrix[1, i];
                    }
                }

                // Scale and bias depth range
                for (byte i = 0; i < 4; i++)
                {
                    projectionMatrix[2, i] = projectionMatrix[2, i] * 0.5f + projectionMatrix[3, i] * 0.5f;
                }
            }

            CameraToScreenMatrix = new Matrix4x4d(projectionMatrix);
            ScreenToCameraMatrix = CameraToScreenMatrix.Inverse();
        }
示例#2
0
        protected virtual void SetProjectionMatrix()
        {
            var h = (float)(GetHeight() - GroundHeight);

            CameraComponent.nearClipPlane = Mathf.Clamp(0.1f * h, 0.03f, 1000.0f);
            CameraComponent.farClipPlane  = Mathf.Clamp(1e6f * h, 1000.0f, 1e12f);

            CameraComponent.ResetProjectionMatrix();

            CameraToScreenMatrix = CameraHelper.Main().GetCameraToScreen();
            ScreenToCameraMatrix = CameraToScreenMatrix.Inverse();
        }