Jump to content
  • Advertisement
Sign in to follow this  
jn_rntkl

Pre-calculated depth buffers?

This topic is 4773 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Many 3d modeling programs support depth map rendering. I was wondering how these maps can be used with directx when drawing static backrounds. Is direct writing to z-buffer possible? I know some games (such as Alone in the Dark) have used static pre-calculated depth buffers.

Share this post


Link to post
Share on other sites
Advertisement
Most API's tend to shy away from direct depth editing like this, but you may want to look at this:

http://www.opengl.org/resources/faq/technical/depthbuffer.htm

Check out item 12.030 for what you're looking for. (Sorry, I don't know a DX equivalent) You'll proabably want to be aware that glDrawPixels() tends to be slow, so you'll want to try and call it as little as possible.

An idea that I had would be to write to the zBuffer once for your static background, then turn off zBuffer writing (not testing) and render all dynamic objects from back to front. If your scene is relatively simple this will work well, and you'll avoid clearing/rebuilding the zBuffer every frame.

Share this post


Link to post
Share on other sites
Quote:
There is no way to do this in recent versions of DirectX.

That's untrue.
Using a pixel shader you can write a value to oDepth.

Edit: I might be wrong about this, seems like the new depth values might only be used for testing against the z-buffer, not actually altering it, or?
If this is the case I can't really see the fuzz about depth-sprites.

Share this post


Link to post
Share on other sites
Actually, I have written a method of doing just this that was going to be included in the last ShaderX book. I'm hoping to get it ready for the next iteration of the book. Two ways of doing it - one is writing to the oDepth buffer, the other involves messing with the zbuffer values in a special way...

Share this post


Link to post
Share on other sites
You are absolutely right, and I am absolutely wrong.

Thanks for pointing this out. I was thinking in terms of old-school Z Buffer blts, etc.

It's ironic that I didn't think of this, because I have used depth-replace for particle systems before with good success.

Another approach would be to simply render the sprites as 'Elevation Maps' as my old white paper shows, or to render them as points with depth.

Anyways, thanks for the correction.

Share this post


Link to post
Share on other sites
shooting in the dark here, but...

simply draw the entire 3D scene once to fill the zbuffer, then perhaps do a buffer copy or something to an auxilary buffer...

then instead of redrawing the scene, copy the saved zbuffer into the depthbuffer, then add object etc...


loading and displaying a million or so untextured triangles shouldn't take more than a couple of seconds or so, so loading wont be that noticable..

this was my approach at a resident evilish game I planed some time ago. :D

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!