- Home /
Why is near clip plane necessary?
OK totally noob question here. I have searched but i cculdn't find a suitable answer. I can understand why the far clip plane is necessary to limit the amount of information drawn on the screen. But why the near clip plane? Why not just start the camera's view from the camera? If you have a movie camera in real life it records the images in front of it, right, not starting at 4 metres in front of it. So what's the deal with this one? Be grateful for an explanation.
Thanks for the replies guys, you gave me a lot to chew on there. Looks much more complicated than i thought, as always with computer graphics!
Answer by Bunny83 · Jun 12, 2011 at 11:53 AM
Also you might take a look at the camera matrix(wikipedia).
Actually it's the other way round. You don't need a far clipping plane but always a near clipping plane. It's a perspective projection with the vanishing point is your camera position. When the near-clipping plane distance would be set to 0 your whole scene would be projected onto a single point.
The mathematical background is that when setting up the projection matrix you have to calculate this:
-(2 * zFar * zNear) / (zFar - zNear)
When zNear is 0 all z values would map to 0.
Here's a nice article about the projection matrix and some tricks how to setup one without far clipping plane.
You don't need a far clipping plane but always a near clipping plane.
Not exactly. You need either a near or a far clipping plane to deter$$anonymous$$e perspective, correct?
@michael-katic: Actually there are no real planes. It's just a value where the geometry is clipped because it's considered outside of the view frustum. Perspective projection in general doesn't need any clipping besides the camera point itself. So projecting the x and y values is quite easy, they are linearly mapped (like an orthographic projection) but in addition divided by the z value. That will give the perspective.
Homogeneous coordinates are between -1 and 1. So 0,0 is the center of the screen. For large z values the projected point will move towards the screen center. At infinity it would be the center.
However, the problem for the graphics card is that it doesn't perform a 3d --> 2d projection but a 3d --> 3d projection. The converted z value is needed for the z buffer. If you take the time to look into the PDF i've linked above, there's a nice image which explains the homogeneous clipspace. If you make the near plane very small (say 0.0000001), that would map half of the z-buffer-range to 0.0000001 - 0.0000002 and the other half to 0.0000002-farplane. This would result in endless z-fighting for most objects (which are usually further way as 0.0000002).
The link to nice article need an f at the end, it should be http://www.terathon.com/gdc07_lengyel.pdf
Since the question was just bumped again I finally saw your comment. Strangely Unity has somehow dropped the final f in the link. Even more strange when I edit my post the f is there... I just clicked "save" again without changing anything and it now has the "f" ^^.
Answer by Oliver Eberlei · Jun 12, 2011 at 11:15 AM
Here is a great thread regarding the question
http://www.facepunch.com/threads/1075270-What-s-the-point-of-the-near-clipping-plane-in-3d-games
The link is 404'd, but here is what Google cached:
The clipping plane is usually represented by a logarithmic scale. This means that if you set your clipping plane at the camera, the distance between the clipping plane and the camera would be zero. Log(0) is -infinity, so the near plane must be greater than 0.