PDA

View Full Version : I'm in a bind :) Viewspace/DepthBuffer



Mongoose
09-21-2000, 09:36 AM
I can't figure out how to do something..

I want to render a skydome and when I do that, all of the triangles will be far away.. ( z values around - 10000 ) or so..

Here is my problem
My View matrix is built like this..
gluPerspective(45.0f,(GLfloat)srn.d[0]/(GLfloat)srn.d[1],1.0f,1000.0f);

Notice the 1.0f , 1000.0f

Now when i goto render my triangles... I turn off depth test and depth buffer writes...

I want to render my triangles but they will all bout of of the 1.0f - 1000.0f range from my view matrix...

How can I get around this????

I don't want to raise my viewmatrix to 10000.0f because then you get lots of jaggies with other polys that are close up.

Does anyone know what I'm talking about???

Please help me out with this bind..!

Thankx,
Mongoose

Mongoose
09-21-2000, 09:39 AM
O yeah and one more thing..

What is the command to turn on/off depth buffer writes??

I know you have to do this
glEnable or glDisable( GL_DEPTH_TEST ) to turn off the testing...

But I want to turn off both the test and the writes..

Thankx,
Mongoose

DFrey
09-21-2000, 10:46 AM
I don't fully understand what your first question is about, sorry. But for your second question, disable depth writes with glDepthMask(GL_FALSE);

Mongoose
09-21-2000, 03:53 PM
Originally posted by DFrey:
I don't fully understand what your first question is about, sorry. But for your second question, disable depth writes with glDepthMask(GL_FALSE);

To make you understand the problem just set up your perspective matrix as I do and render a few triangles off in the z distance by about 5000...

I'm trying to figure out a way to turn the distance check off!

DJ Tricky S
09-21-2000, 05:30 PM
It sounds like you are experiencing problems with depth-buffer precision. A couple of options that come to mind are:
- minimize the distance between the near & far clip planes, either by bringing the far clip plane closer to your viewpoint or moving the near clip plane out a bit
- use a higher-prcision depth buffer (eg, 32-bit)

mcraighead
09-21-2000, 07:08 PM
Originally posted by Mongoose:
I'm trying to figure out a way to turn the distance check off!


That can't be done (the distance check, by the way, is clipping).

Instead, disable GL_DEPTH_TEST and draw the skybox/skydome safely within your near/far clip planes. For example, if you have near and far of 1 and 1000, drawing a sphere of radius 30 is definitely safe.

The depth information is still used for other things, such as fog and perspective correction, but for perspective correction, only the ratios of W values matter, not their absolute values.

Note that disabling GL_DEPTH_TEST automatically turns off depth writes. If you want to write to depth but not test it, you need to enable GL_DEPTH_TEST and set the DepthFunc to GL_ALWAYS, with the DepthMask set to GL_TRUE.

- Matt