PDA

View Full Version : w Vertex coordinate and depth range

charliejay
11-30-2005, 06:52 AM
Hi all, my apologies in advance if this is not considered an advanced question.

Basically, i'm wondering what the best way to achieve an infinite (or just very large) view distance is.

Am currently considering doing something with the w coordinate, perhaps in software, that maps all the vertices into a specified depth range - the idea being to squash the vertices in a large depth range into a much smaller depth range, without affecting the projected locations of the vertices.

This might also aid in pushing the near clipping plane out, as suggested by the red book.

Am curious about how one might do this, and what pitfalls to beware of.

Any advice, experiences, or references most welcome...

CJ

holdeWaldfee
11-30-2005, 07:39 AM
I am not sure if I understand your problem.

You can simply use very high values for far clipping plane.
Z-fighting will happen at high distances with the crappy 24 Bit depth buffer precision of consumer cards however.
There is nothing efficient that can be done to get rid of this problem as far as I know.

memfr0b
11-30-2005, 07:57 AM
You can create an infinite view frustum, using the projection matrix presented in nVidia\'s Robust Shadow Volumes Presentation (http://developer.nvidia.com/object/robust_shadow_volumes.html) .

Tom Nuydens
11-30-2005, 11:58 PM
One of the things you could try to do is to partition your depth range. Batch the visible objects in your scene based on their distance from the camera, and fit the near and far clipping planes to each batch. If you then draw the batches back to front, and clear the depth buffer in between batches, you can use the full precision of the Z buffer for each individual batch.

knackered
12-01-2005, 02:22 AM
yeah, so long as you don't have anything crossing the boundries, like a floor or a sky. Changing the projection matrix between the batches doesn't guarentee you'll get a perfect edge match.

holdeWaldfee
12-01-2005, 02:27 AM
I tried this a while ago and it did cost around 40% frame rate in a fillrate limited scene.

My frustration about the toyish 24Bit depth buffer on consumer cards causes a high pressure in my head.

But hey! 32Bit fragment program precision is way more important because games really need a thousand times higher contrast ratio and general purpose programming on the GPU is just around the corner! [/sarcasm]

charliejay
12-01-2005, 09:37 AM
Thanks for all the replies, folks!

There's a formula for depth buffer precision somewhere on the board, i'm gonna go look for that, and check out the infinite view frustum...

Am still trying to find a nice way of expressing exactly what it is i'm thinking of, i'm not sure at the moment whether or not the w coordinate can actually help with depth buffer precision...

Thanks again, CJ

holdeWaldfee
12-01-2005, 11:42 AM
The depth buffer precision is described here: http://sjbaker.org/steve/omniv/love_your_z_buffer.html

It doesn't matter for the depth buffer how you do your projection, so changing the W-values won't help you.

charliejay
12-07-2005, 09:42 AM
Many thanks again, folks...

An infinite view volume sounds like what i'm looking for, if the w coordinate won't be of any use. Multiple depth ranges would br better, but I'll leave that for another day, I think; it sounds rather tricky!

Regards, CJ

Dark Photon
12-07-2005, 02:05 PM
charliejay:
An infinite view volume sounds like what i'm looking forIf you can't find it on the board, check out Chapter 9 in GPU Gems (pg 145-7) pertaining to stenciled shadow volumes. It describes the approach and gives you the matrix.

holdeWaldfee
12-10-2005, 03:59 PM
I thought you wanted to get a better depth buffer precision at high ranges?

An "infinite" view frustum doesn't help at all there.
You can simply use very high zFar frustum values to be able to get stuff drawn far away from zNear.
But the depth buffer precision will suck there (especially with toyish 24Bit precision).

Getting better depth buffer precision at higher ranges without heavy performance hits (for game like applications) is sadly a no-go in my books. :(