• Advertisement
Sign in to follow this  

Depth Buffer Issue

This topic is 4365 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

I'm working on an adventure game ,the backgrounds being pre-rendered ,and the camera being still in every scene.What i want to do is load a depth surface from a file and set it as the device's depth surface.How can i load a depth surface? What format should i use? How can i export the depth buffer from 3dsmax when i render a scene? Thanks in advance

Share this post


Link to post
Share on other sites
Advertisement
The only depth surface which can be read or written is D16_LOCKABLE, and more and more cards are supporting it. Allowing you access to the depth values removes any optimization tricks of the GPU. But you can get around it with shader 2.0.

Simply render your scene to one buffer, then, either with MRT or a second render, render depth values to a second buffer. You'll need a card with support for 16 or 32 bit float formats for decent precision, ie: D3DFMT_R32F. Save this "depth" image along with your regular color image.

When using, read the background image and depth color image as textures when rendering a big quad. Set the depth output value in the shader to the contents of the "depth" image. The scene can now be rendered.

Writing to depth will disable many optimizations on the GPU, so an even better option may be to render the scene, then the background. The depth writes of the background should ensure everything is still correct. This method won't work along with partially transparent objects though.

Share this post


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

  • Advertisement