   Planet rendering and clip planes.
  Hi there,i''ve got a blooming enormous sphere to render (a proto-planet). Its radius is around 6379000 (the radius in meters of the earth).  I haven''t bothered using any kind of scale modifier.  The trouble is, when I get right up close to the planet (say around 10000 kilometers, the triangles start to flicker "on/off".  I''m sure this isn''t Z fighting, because I''ve disabled Z depth test for rendering the planet.  So it must be something to do with my clip planes and possibly to do with accuracy when you are right up close to an object.  Anyway, the projection I setup for the planet is as follows:(where distance is distance from camera eye to sphere)glDisable(GL_DEPTH_TEST);glMatrixMode(GL_PROJECTION);glLoadIdentity();gluPerspective ( fieldOfView, windowWidth, windowHeight, 0.1, Distance);Any ideas on what could  be going wrong here?  I would like to think I could scale right up to, say 1 meter from the surface, but perhaps this isn''t possible?Thanks 
  Well the 5th parameter of gluPerspective() is setting the distance to the far clipping plane, so ideally this should be greater than the distance from the camera to the planet. Otherwise the plane might intersect your planet, this could be what it causing your problem.In most applications I have seen people just set it to a predefined maximum distance say 1000.0f. In your case you could just add a little extra onto your Distance to move the clip plane back a bit more, this might fix it.  [edited by - IronBat on February 18, 2004 6:27:08 PM];Well, I''ve tried many different far clip plane values.  At the moment, I''ve set it to much greater than the distance to the planet (like 10 * distance to the planet).  The problem I think is either with the near clip plane or the distance between the clip planes.  When I''m up close to the planet (100 meters from the surface), it flickers like hell.  When I''m 10000 meters from the surface looking towards it it still flickers like hell.  When I''m 100000 meters away, its ok. ;Should I be bumping this!?  Still having trouble with flickering polygons!   ;  You should keep at worse a ratio of 1:10000 between your zfar and znear values. Try to push as far away as possible your znear plane. After all if you''re flying 1 kilometer above your planet, you could have a znear of 1 kilometer.Y.;quote:Original post by Ysaneya  You should keep at worse a ratio of 1:10000 between your zfar and znear values. Try to push as far away as possible your znear plane. After all if you''re flying 1 kilometer above your planet, you could have a znear of 1 kilometer.Y. Hmmm, will check my calculations when I get home from work.  Something in there must be fubar, because I tried setting the near clip plane to just in front of the planet already and it seems to cut through it! (I mean distance from camera to planet center minus radius minus some other value).;Update:I worked out that the problem is the accuracy of the GL floating point projection matrix (even if I pass in doubles, it still operates on floats).  When I scaled down my planet from meters to kilometers, the problem went away.   ;  I had the same problem in my planet simulation.What you could also try (I haven''t yet, but will soon) is the DEPTH_CLAMP extension which instead of clipping your polys just clamps the z-value to the z-value of the near/far plane. This should also fix the problem without any need of re-scaling.Btw, is there any way to make GL use double precision?;quote:Original post by Lutz   I had the same problem in my planet simulation.What you could also try (I haven't yet, but will soon) is the DEPTH_CLAMP extension which instead of clipping your polys just clamps the z-value to the z-value of the near/far plane. This should also fix the problem without any need of re-scaling.Btw, is there any way to make GL use double precision? I'm pretty sure you can't make it do that.  Its the drivers rather than OpenGL, because gl does allow you to pass in double precision numbers, I guess when passing them into the driver it gets converted to the gfx card native format, which in the case of most desktop gpus is floats.Anyway, I'll take a look at depth clamping (never heard of that one before).btw: its an NVIDIA extension, does ATI or any other driver support this? [edited by - Robbo on February 20, 2004 7:17:32 AM];quote:Original post by Robbo  Update:I worked out that the problem is the accuracy of the GL floating point projection matrix (even if I pass in doubles, it still operates on floats).  When I scaled down my planet from meters to kilometers, the problem went away.Make big objects managable by scaling them down and bringing them proportionally closer to the camera.http://www.gamasutra.com/features/20020712/oneil_01.htm 