4
\$\begingroup\$

is there a way to mix multisample and non multisample rendering in Directx11? It seems that when I create a multisampled render target I always get a multisampled rendering, regardless of the value of the MultisampleEnabled flag of the RasterizerDescription.

Microsoft says:

"To use multisampling, set the enable field in the rasterization description, create a multisampled render target, and either read the render target with a shader to resolve the samples into a single pixel color or call ID3D11DeviceContext::ResolveSubresource to resolve the samples using the video card."

and also

"There are no restrictions for mixing multisampled and non-multisampled rendering within a single render target."

But then in the rasterizer description page it says:

" For feature levels 10.1 and higher, the setting of MultisampleEnable has no effect on points and triangles with regard to MSAA and impacts only the selection of the line-rendering algorithm as shown in this table...

"

So, how can I temporarily turn multisampling off on a multisampled render target, in order to draw part of the scene without multisampling?

| improve this question | | | | |
\$\endgroup\$
1
\$\begingroup\$

As far as I know you cant.

You will have to create another render target without MSAA and do one of two things:

  • Copy the MSAA target into the non-MSAA, resolving the subsamples, and keep rendering in the non-MSAA for your alpha geometry (wild guess that this is why you need MSAA off)
  • Render non-MSAA to the non-MSAA target and merge the two render targets, that only works for opaque passes unless you use depth peeling (http://en.wikipedia.org/wiki/Depth_peeling).

In theory you could use the pixel shader and render a 1-pixel larger triangle and kill pixels outside of the intended triangle boundaries but in reality rounding errors will likely create a mess and discarding fragments in the shader has a small performance impact compared to non-discarding shaders on some hardware.

(If anyone knows a better solution that would be very much welcome.)

| improve this answer | | | | |
\$\endgroup\$

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.