Jump to content

View more

Image of the Day

Inventory ! Va falloir trouver une autre couleur pour le cadre D: #AzTroScreenshot #screenshotsaturday https://t.co/PvxhGL7cOH
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Any way to save and restore the Z-buffer?

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
2 replies to this topic

#1 DvDmanDT   GDNet+   

1911
Like
0Likes
Like

Posted 08 February 2014 - 07:41 PM

Hi, I was wondering if there's a way to save and restore the Z-buffer. What I want to do is pretty much to create a G-buffer, save the Z-buffer, do stuff, including creating shadow maps etc. Then restore the Z-buffer before rendering the forward pass with particles and other translucent surfaces. Is there any sane way to do this?

 

I'm using XNA with the intention of moving on to MonoGame in the near-ish future.



#2 Matias Goldberg   Members   

9479
Like
0Likes
Like

Posted 08 February 2014 - 10:20 PM

I'm not an XNA user, but the D3D9 api surely allows creating multiple z buffers, so that you can "save" one for later usage while using another for write access; and it is normal to the rendering process (SetDepthStencilSurface)

 

I don't know if XNA allows access to it though.



#3 phil_t   Members   

8002
Like
2Likes
Like

Posted 09 February 2014 - 11:05 AM

You might try RenderTargetUsage.PreserveContents, although that means you'll be using the same render target - so it's not an option if you'll be sampling from the same one you used when creating Z-buffer. I'm also not sure if that's supported in MonoGame. 

 

The depth buffer is tightly-coupled with the render target in XNA.

 

Another option (this is what I do), is to render depth values to a render target during your G-buffer pass, and then use that render target to render to the z-buffer during your forward pass (by outputting DEPTH from your pixel shader, and using a BlendState that disables color writes).






Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.