2
votes

I am trying to achieve a simple task (or so I thought) in XNA 4.0. I have objects that need to glow (rendering and Gaussian blurring them and then adding them to the main scene). These objects can be at different depths so I will need to make sure that they are obscured by objects in front of them in the main scene. It's 3D.

Because depth buffers cannot be re-used in XNA 4.0, I am having a hard time figuring out how I can achieve this?

I can find no examples or tutorials or explanations of this process. The bloom post process example of XNA also does not do exactly what I need, as it post processes the entire scene.

I know that I can preserve RenderTarget info by using PreserveContents, but it sounded like it was slow. Is there a way to achieve this without using PreserveContents?

Any help would be appreciated. Thank you, Riaan.

1
A visual example of what you want to do would be tremendously helpful. Can you mock something up?cwharris
Mmm. I can't seem to upload the image as I'm new. Here is a link to it: postimage.org/image/cwmw2cglh/a6790034Riaan Oberholzer
What exactly do you mean by 'depth buffers cannot be reused'? XNA lets you do almost anything with depth buffers.Kendall Frey
According to the Shawn, depth buffers cannot be shared between Render Targets (forums.create.msdn.com/forums/p/64179/397431.aspx). As soon as you set a new rendertarget, the old RT's Depth Buffer is resolved automatically and cannot be used for further depth testing.Riaan Oberholzer

1 Answers

1
votes

I'd try to render the glowing objects using a second rendertarget to store its depth... this is a multi target rendering technique...

I suppose that you will need another for the non glowing objects..(or use the same, storing both depths with an addtive blending) to compare them at postproccess time...

later in the post process it would be possible to know if the glowing object is visible or is hidden.