Archived

This topic is now archived and is closed to further replies.

Silly_con

Perspective ZNear plane

Recommended Posts

I have heard that the best value for Z-near plane in perspective projection is 1.0f (I heard that with this value you get less clipping problems, and is best for Zbuffer, but I don''t understand much), so I put it in my gluPerspective, but, with this value I can''t come near an object because the camera clip it. It''s true that is the best value, if so, how I can come near and object without clipping it? (I see that in the shotem up games, when you come near a wall, the wall is not clipped, what value is used in this games?) thanks

Share this post


Link to post
Share on other sites
Let me just rudely explain something.If your near plane is 1.0 that means that the objects will become to clip 1 unit away from the current''s camera position.That''s they get clipped so early.Try setting 0.1 or 0.01 and see the results

The PAIN is coming...this summer!!!In cinemas everywhere.

Share this post


Link to post
Share on other sites
why should a near plane 1 away from the camara point be any bad? ... if you use 0.1 as near and 1000 as far, your z-test resolution is about one ten-thousands-th worser than if you used 1 for near

Share this post


Link to post
Share on other sites
Just scale your "world" so that the distance 1 is quite small, then limit your approach to a wall (via some form of collision detection) so that you cannot get near enough for the camera to clip it.

Simple!

It all depends on what sort of game you are making - an indoor FPS can probably get away with a near clipping plane of 0.1 or less, but if you try this on an outdoor environment with a far clipping plane of 1000 or more then you will get z-buffer problems with the further away polygons.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
That means that in a game that have indoor and outdoors I have to change the near plane in every level/zone?, like return to castle of wolfenstein that have indoors and outdoors

Share this post


Link to post
Share on other sites
*former washington: ''666_1337'' kamikaze-d with ''mig29h carriing 4 at22s equiped with nuclear warheads'' injuring ''Anonymous Poster'' by a splash-damage amount of 50x (times) his life, a ''got hit by crashing aircraft-damage'' of 9x his life and a ''heat-damage'' of other 50x his life @ 2 minutes ago* [connection reset by peer]

...
so he maybe doesn''t think return to castle wolfenstein would be an indoor & outdoor game - for any longer

Share this post


Link to post
Share on other sites
i guess he ment scale up -> glScalef(x, x, x) { x | x>10 }, said mathematically
if you set x to be about 10, it would have the effect that your near plane apears to be like if you would use one with a distance of 0.1 at a normal scale.
don't forget that the object (s) needs to be placed (here) ten times farther away from you, to see the same thing. i suggest you call glScalef() directly behind the first modelview-reset, and setup a #define parameter for the physics (if they are given)

[edited by - 666_1337 on April 30, 2003 3:18:37 PM]

Share this post


Link to post
Share on other sites
scaling up everything might fix the clipping plane-problem, but there is still the depth one. you could *emulate* the z-test-algorithm and store the point''s distance in a double-precision floating-point map, but this would be much slower then OpenGL''s z-test and you would have to write your own system for drawing, since glVertex3fv or glArrayElement (and the other ones) both call the z-test-func automatically, so the z-test func cannot be replaced without having to write an function that executes both your own z-algorithm and the gl-function...

  
e.g.

void myVertex3f(GLfloat x, GLfloat y, GLfloat z)
{
vertexCount++;
myTriangle -> vertex[i] = new vertex(x, y, z);
if(!vertexCount % 3)
{
vertexCount = 0;
precessDepthTest(myTriangle);
}
glVertex3f(x, y, z);
}

Share this post


Link to post
Share on other sites