protected CameraComponent GetUICameraComponent(UIComponent uiComponent) { var virtualResolution = uiComponent.Resolution; var nearPlane = virtualResolution.Z / 2; var farPlane = nearPlane + virtualResolution.Z; var zOffset = nearPlane + virtualResolution.Z / 2; var aspectRatio = virtualResolution.X / virtualResolution.Y; var verticalFov = (float)Math.Atan2(virtualResolution.Y / 2, zOffset) * 2; var cameraComponent = new CameraComponent(nearPlane, farPlane) { UseCustomAspectRatio = true, AspectRatio = aspectRatio, VerticalFieldOfView = MathUtil.RadiansToDegrees(verticalFov), ViewMatrix = Matrix.LookAtRH(new Vector3(0, 0, zOffset), Vector3.Zero, Vector3.UnitY), ProjectionMatrix = Matrix.PerspectiveFovRH(verticalFov, aspectRatio, nearPlane, farPlane), }; return(cameraComponent); }