Search code examples
c#xnaperspectivecamera

C# XNA - Matrix.CreatePerspectiveFieldOfView - Extend how far camera can see


i am using the following code to setup my camera. I can see the elements in a range of some 100 fs. I want the camera to see farther.

projection = Matrix.CreatePerspectiveFieldOfView((3.14159265f/10f), device.Viewport.AspectRatio, 0.2f, 40.0f);            

How to do it ?


Solution

  • Look at the documentation for Matrix.CreatePerspectiveFieldOfView.

    The last two parameters are the near and far plane distances. They determine the size of the view frustum associated with the camera. The view frustum looks like this:

    Everything in the frustum is in the volume that the rasteriser uses for drawing - this includes a depth component. Everything outside this region is not drawn.

    Increase the distance of the far plane from the camera.

    But don't increase it further than you need to. The larger the distance between the near and far plane, the less resolution the Z-buffer has and the more likely you will see artefacts like Z-fighting.