Pre-calculated depth buffers?

Started by
6 comments, last by jn_rntkl 18 years, 9 months ago
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.
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.
// The user formerly known as Tojiro67445, formerly known as Toji [smile]
There is no way to do this in recent versions of DirectX.
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.
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...
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.
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
"Game Maker For Life, probably never professional thou." =)
Thanks for your posts. Now I'll have to explore a bit.

This topic is closed to new replies.

Advertisement