View Full Version : Drawing order, skyboxes, and translucent objects

12-14-2004, 10:50 PM
Here is the problem...
My scene manager is set up to draw opeque objects first, then skyboxes, then translucent objects in order to minimize overdraw and get proper blending... my problem is with the skyboxes... the size of the skybox is arbitrary, since a skybox is a cube and perfectly centered around the camera, size shouldnt matter... currently set to 10.0 in order to avoid the far and near clipping planes. upon drawing the skybox instructs the renderer to disable z-writing, lighting, and fog... draws... then resets them back to their prevoius states... the problem is that any object further away than 10.0 units gets overdrawn... the obvious solution would be to also instruct the renderer to disable the depth test and draw the skybox first... well that totally defeats the purpose of the drawing order explained above and produces a lot of overdraw... i could simply make the skybox bigger... say just in front of the far clipping plane... but the far plane will never be the same across different applications... i could make the skybox smaller... say 1.0 or 0.5.. well what about the near plane... so... reset the size of the skybox whenever the projection is modified... well thats a lot of mess too and kills the elegantness of a simple skybox class... is there a way to disable distance clipping... or a way to only write to the color buffer if the pixel's z has not been written to...??? i.e. 1.0... and without using the stencil buffer... ( stencil shadows )... please help... this is guaranteed to make me crazy soon...

12-14-2004, 11:54 PM
Your problem is simple to solve. Just use
glDepthRange(1.0, 1.0) when you draw the sky. This moves the sky´s z-values away as far as possible, regardless of its physical dimensions. This way it will never overwrite level-geometry.

12-15-2004, 06:32 AM
Excellent... Works perfectly... My sanity has been saved for another day... Thank you very much...