MSAA and offscreen render target issue

Started by
3 comments, last by Wilhelm van Huyssteen 9 years, 6 months ago

Hi.

Im probaly just missing something small but i cant get anti aliasing working with offscreen rendering. When i set the sample count above 1 the offscreen textures seem to always return (0,0,0,0) when i sample them regardless of what im rendering to them and even if I clear them to a different colour. Rendering to the backbuffer works with anti aliasing though.

to test it im trying 2x aa.

ive set the sample count to 2 in the DXGI_SWAP_CHAIN_DESC and in the depth texture and in all render targets. Is there anything else i need to do? (The Quality for all of them is set to 0)

I can post code but im not sure were the problem would be. Please ask for more information/code if needed.

Thnx in Advance

Advertisement

You can't sample from an MSAA texture in a shader using a regular Texture2D object. If you do this, the debug runtimes will report an error when you draw using that shader. So your first step should be to turn on the debug runtimes if you don't currently have them enabled, since it's an invaluable tool for solving bugs like these. To turn it on, pass D3D11_CREATE_DEVICE_DEBUG as the Flags parameter of D3D11CreateDevice.

Now to make your setup work, the easiest thing to do is perform an MSAA resolve to produce an antialiased result from your MSAA texture. To do this, you'll want to create another 2D texture resource that's the same size and format as your MSAA texture resource, except with a sample count of 1. Then during your render loop, once you've finished rendering to your MSAA render target you can resolve the results to your non-MSAA texture using ID3D11DeviceContext::ResolveSubresource. Then you can have your shader sample normally from the non-MSAA texture, and it will work correctly.

Im not trying to sample from a MSAA texture in particular (I was just under the impression that all render targets needed to have their sample count set to the AA level as wel).

I just want whatever is rendered to the backbuffer to be anti-alaised (In opengl i could do this simply by enabling multisampling when creating the context. I just want the same in directx). I have set the count of the render targets back to 1 but i stil have the same problem.

As far as using the debugger goes my engine is written in java and ive only written some c++ bindings (that i export as a .dll) so i can use directx. Dont know if it would be possible to still use the debugger but it would certainly be nice.

EDIT: found the issue. Both the depth buffer i use with the back buffer and the depth buffer i use with the render targets had their counts set to the AA level whereas only the depth texture that i use with the backbuffer should have had that count set. Im stil wondering if there might be a way for me to get some debug info back with my setup like i described in the above paragraph.

You should still be able to get the debug messages by using DebugView to view the native debugger output stream.

Thanks il take a look at that.

This topic is closed to new replies.

Advertisement