Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
BernieLomax
May 29, 2002
Sorry if this has been asked before, but I have problems with precision using the depth buffer. First I'm rendering stuff to several depth buffers, and afterwards I want to merge them by drawing them on top of each other with depth testing enabled. And afterwards I am using the depth test GL_EQUAL in order to shade everything. However it does not work very well. I do find that by using buffers with the same precision I get better results, but I have yet to find a combination that works. Any ideas?

Adbot
ADBOT LOVES YOU

BernieLomax
May 29, 2002

OneEightHundred posted:

You can't really do this because the depth buffer values range from 0-1, the projection matrix remaps distances between the nearplane and farplane to that range. That means if have, say, one depth range...

Camera --> N[----A----B----]F
... and chop it into two depth slices...
Camera --> N[----A--]F N[--B----]F

... then you need to clear the depth buffer after after you draw the distant slice anyway, otherwise you can get out-of-order objects like this crap:
Camera --> N[--B-A--]F

The drawback of course is that by clearing the depth buffer, you are eliminating B from the depth buffer. What you need to do is make sure that any objects that are in a depth slice (even partially) get drawn in that slice.

.... Alternately, make sure you're creating the depth buffer with a reasonable precision and try adjusting your nearplane/farplane values.
What I need to do is to exactly copy the depth buffer from one FBO to another (or the main output). The stuff I am rendering is the exact same on both, but with differing stencils etc. However the internal format differs from what you read, so you'll lose some details.

I'm trying to work around this, but still would love if there was a way.

edit: Solved. I made a fragments-shader that reads from a depth texture and compares the fragment-z and draws with a threshold. Works extremely well.

BernieLomax fucked around with this message at 09:40 on Nov 5, 2008

BernieLomax
May 29, 2002
A thank you for this thread: this thread was invaluable for getting my demo outta the door.

I couldn't make the original demo I aimed at, but made this one quicky in two days when I realized the original one was desitened to fail

Anyway: http://http.de.scene.org/pub/parties/2008/kindergarden08/demo/rund.zip
Requires a newer card and breaks horribly on non-supported cards. If you have a <=DX9 card I would love to supply a debug version. It uses NPOT and really nothing else but high polys.

BernieLomax fucked around with this message at 00:06 on Nov 23, 2008

BernieLomax
May 29, 2002
As far as I remember, for clamped texturing the speed is almost the same since you avoid a mod for every texture lookup.

BernieLomax
May 29, 2002
This might sound silly, but I got this to work by setting the desktop to 16 bit on my really crap computer. Wild guess?

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply