I have a DirectX11 application, which has multisampling / anti-aliasing enabled. However, I want to add an effect that requires a render-to-texture step. When I add this extra step, I lose all anti-aliasing. Here's basically what I'm doing:

1) render scene to texture

2) render texture to screen (with some effect, say blurring or something).

I've tried enabling multisampling on the render texture, but i'm not sure how to get it to work. I've made it use 8 samples and specified D3D11_DSV_DIMENSION_TEXTURE2DMS, but apparently that step required me to use Texture2DMS in the shader. But now I don't know how to sample a Texture2DMS in the shader, because I can't just pass in the textures coordinates, I have to pass in a sample index, which I don't know how to calculate.

How to I use render to texture effects while preserving multisampling / anti-aliasing?


The idea behind multisampled textures is to let you explicitly fetch each of the individual samples in a shader. You can gather all 8 samples and implement the MSAA resolve (the process by which multiple samples are resolved into a single sample) yourself, but I do not think that is what you want.

In OpenGL, you work around this problem by blitting a multisampled source texture into a singlesampled destination, which takes care of MSAA resolve for you. Then, in your shader you use the anti-aliased singlesampled result instead of the original multisampled texture.

D3D has this same functionality, in the form of ID3D11DeviceContext::ResolveSubresource (...). Unfortunately, all I can do is point you to that function because I have no experience actually using it.

  • \$\begingroup\$ ID3D11DeviceContext::ResolveSubresource() is constrined to just the resolve step. Source and destination have to have the same size, etc. (see documentation). \$\endgroup\$ – Pablo H Jul 18 '18 at 19:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.