- Home /
Is there a way to render the area inbetween the camera and the near plane?
Basically I want to render everything close by, without a limit, as if the near plane is at 0 distance from the camera. I understand this could give problems for the z-buffer, but for all I care the area ibetween the camera and the near plane can be rendered without reading and writing the z-buffer. So is there any way to do this?
I don't think so. By definition all object between camera and near plane are occluded. This is the reason for view frustum
By the way, what do you need this functionality for? Your saying that you don't need the z-buffer gives me the impression that you have some kind of 2D content to draw in front of a 3D scene - but that would be the job of an OnGUI() function.
When you're on a planet, I render the planet-sphere with a different camera before the camera that renders the local scene (player, terrain, etc.), like a 3d skybox. Because of this I want the near plane distance for the space cam to be (nearly) 0, as the camera is nearly on the planet-sphere surface.
The only reason I can think of for the near plane limitation is for the z-buffer, so I thought if I only render the 1 planet, then I don't need the z-buffer, so I thought maybe it would be possible then.
Answer by Bunny83 · May 06, 2012 at 12:25 PM
No that's not possible for perspective cameras. A camera is infinitely small at it's origin. The 4 "rays" of the perspective projection meet at the origin. Each of these rays go through one of your screen corners. It's actually the space between your monitor and the virtual eye position (which is always behind the monitor). Also like you've mentioned when you use a very small nearplane the z-buffer accuracy is getting really bad.
An ortographic camera can have a negative nearplane since the "4 projection rays" are parallel.
makes sense, I still don't get why there's the near plane limitation though, appart for z-buffer's sake. I mean I get that something at 0 distance from the camera would become infinitely big, but why is that a problem ?
well, anyway, it's not that big of an issue, I'll just try to do it some other way.
Thanks for the help.
Well 0 distance means ultimatively your screens left coordinate and the the right coordinate are the same... "0". The near plane is your virtual screen. It's the actual "surface" on which everything is projected. It can be very small since we work with floating point values, but it can't be 0. See 3D projection (wikipedia).
The next problem arises when you use a very small near plane (~0.00001) you loose precision. See Accuracy Problems(wikipedia)
When the near plane is set too near (< 0.1, for instance), far objects that intersect each other present ugly artifacts due to the Z-fighting - the boundaries flick crazily when the camera moves or rotates. A possible way to extend the depth buffer precision is to use two cameras, one with a near plane and a short far plane, and the other covering the area beyond this far plane. This is a limited solution, however, because big objects may be partially rendered by both cameras, still producing ugly artifacts at the near camera's far plane.