Malmer

Hi,

I have this little problem you see. I want to render to multiple render targets (I'm going for Windows only. No xbox 360). Works fine and everyone is happy and the world is a pretty place.

Until I turn on multisampling on my graphics device (PreferMultiSampling=true).

Then I get nothing (or whatever was left in the video memory). If I only use one render target it works fine. Two, not so much. I have created the render targets using the same SurfaceFormat and multisampling as my device uses since I read somewhere that you can't have different multisample types on the rendertargets and the depthbuffer.

Anyone got a clue on how to solve it In my case I can live without multisampling. I might even, at then end, decide it is too slow, but I do believe this is a problem more people than me could encounter, so it is worth researching.

I'm not entirely sure how XNA works with the depth buffer when you use rendertargets. Does it keep it as it was or does it switch it automatically

Thanks for any help.

(Oh, and XNA API devs: Working with rendertargets in XNA is really nice! You did a really good job in abstracting how DirectX does it. Together with a spritebatch one saves much boring time creating a vertex buffer and stuff when presenting a target surface to the screen.)



Re: XNA Framework Multiple render targets and multisampling

Peter D.

Currently XNA does not support multiple render targets.





Re: XNA Framework Multiple render targets and multisampling

Malmer

Sure it does. I'm rendering with multiple render targets as we speak. It does not support it on the x-box though, but I develop for Windows where it works like a charm, except for multisampling.



Re: XNA Framework Multiple render targets and multisampling

Ralf Kornmann

Peter, XNA supports multiple render targets as long as the used hardware supports it too.

Malmer, this problem could not be solved as it based on a Direct3D restriction for using multiple render targets. If you use more than one render target at the same time none of them could be a multisample render target.

I am not sure what you want to know about the depth buffer behavior but setting a render target does not change the currently used depth buffer.






Re: XNA Framework Multiple render targets and multisampling

Malmer

Thanks. You answered all my questions. Figured it was something like this. Good to be sure though.



Re: XNA Framework Multiple render targets and multisampling

Slovikosky

Hello Ralf,

I would very much like to know how multiple render targets is done. Are there any code samples available which illustrate the technique Or could you possible post / email something that illustrates two Windows with two different sets of data being rendered My goal is to have a large terrain surface with multiple aircraft in flight with user selectable views / panning /zooming from in-flight and on the ground.

In the past I have created multiple swapchains on the same D3D Device with reasonable performance. Is there a major performance impact in XNA using multiple render targets In general how does compare to DirectX 8.1 and 9.0c swapchains

Best Regards,

Slovikosky





Re: XNA Framework Multiple render targets and multisampling

Shawn Hargreaves - MSFT

Slovikosky,

I think you're confused about what multiple render targets are. That functionality is for writing more than one color value out from your pixel shader, and is used for techniques like deferred lighting. All the render targets have the same polygons with the same camera view, it's basically just a way of extending the output format to more than 32 bits.

It sounds like what you're looking for is just the ability to render different scenes to different buffers, one after the other. That is well supported on all graphics hardware these days. In XNA you do this using the RenderTarget2D type: you'll find lots of discussion about that on the forums.