0
\$\begingroup\$

I'm having a little trouble with XNA, but I doubt it's specific to the framework.

I draw a few 3d models to 1 rendertarget with multisampling turned on, and it works fine. If I draw the same scene to 2 rendertargets (of course the second one gets a different output (configured this in HLSL shaders)) with multisampling turned on, I get absolutely no output. Nothing. Blank. Also, when I render to both outputs but turn off multisampling, it works perfectly (but looks hideous due to a lack of antialiasing).

The strange thing is: This happens on my desktop (Nvidia GTX 560 Ti), but not on my laptop (Intel HD Graphics 4000, which sits on the CPU). On my laptop, it outputs just fine to both rendertargets and multisampling turned on.

Can anybody explain what could be wrong? I won't copy all my code here but just to clarify:

graphics.PreferMultiSampling = True
RT_Light = New RenderTarget2D(device, ClientWidth, ClientHeight, False, SurfaceFormat.Color, DepthFormat.Depth24, 0, RenderTargetUsage.PreserveContents)
RT_Scene = New RenderTarget2D(device, ClientWidth, ClientHeight, False, SurfaceFormat.Color, DepthFormat.Depth24, 0, RenderTargetUsage.PreserveContents)
device.SetRenderTargets(RT_Scene,RT_Light)
'Draw

Works but looks hideous

graphics.PreferMultiSampling = True
RT_Light = New RenderTarget2D(device, ClientWidth, ClientHeight, False, SurfaceFormat.Color, DepthFormat.Depth24, 4, RenderTargetUsage.PreserveContents)
RT_Scene = New RenderTarget2D(device, ClientWidth, ClientHeight, False, SurfaceFormat.Color, DepthFormat.Depth24, 4, RenderTargetUsage.PreserveContents)
device.SetRenderTarget(RT_Scene)
'Draw

Works but obviously only draws to one rendertarget

graphics.PreferMultiSampling = True
RT_Light = New RenderTarget2D(device, ClientWidth, ClientHeight, False, SurfaceFormat.Color, DepthFormat.Depth24, 4, RenderTargetUsage.PreserveContents)
RT_Scene = New RenderTarget2D(device, ClientWidth, ClientHeight, False, SurfaceFormat.Color, DepthFormat.Depth24, 4, RenderTargetUsage.PreserveContents)
device.SetRenderTargets(RT_Scene,RT_Light)
'Draw

Works on my laptop, but not on my desktop.

Again, to clarify: The top picture is what my laptop shows (with multisampling and multiple render targets), and the bottom picture is what my desktop shows with the same settings: Laptop Desktop

\$\endgroup\$
2
  • \$\begingroup\$ Are you using Visual Basic? What is the model of the onboard graphics on your laptop? \$\endgroup\$ Sep 30 '15 at 0:27
  • \$\begingroup\$ Yes I'm using Visual Basic. That shouldn't matter because under the hood, it does exactly the same as C#. And I updated my question to include the onboard gpu of my laptop (Intel Graphics HD 4000) \$\endgroup\$
    – Peethor
    Sep 30 '15 at 5:54
0
\$\begingroup\$

Depending on the age of your laptop, it is very possible that the onboard graphics inside your laptop do not support multisampling, while the graphics card in your desktop does.

According to the MSDN article on PreferMultiSampling:

PreferMultiSampling is ignored if no hardware is available that supports multisampling.

Thus your game will not throw an error and will simply look crappy if the hardware can't mutlisample on the backbuffer.

So from here you have two options: let your users know that your game will only work on modern graphics cards or not use multisampling at all.

\$\endgroup\$
1
  • \$\begingroup\$ It sounds reasonable, but my laptop actually DOES multisample properly. And my desktop DOES multisample, but only when drawing to one rendertarget at a time. I'll get to my laptop in an hour or so and then I'll comment my laptops gpu \$\endgroup\$
    – Peethor
    Sep 30 '15 at 4:30
0
\$\begingroup\$

Alright, I found out what the actual problem was. Let's ignore my laptop for a moment, I'll get back to it at the end of this answer. XNA uses DirectX 9. DirectX 9 does NOT support MSAA (Multisampling antialiasing) on MRT (Multiple render targets). Strangely though, instead of throwing an exception or showing a warning, I just don't get any output.

Fair enough, but why does it work on my laptop then? I'm assuming that my laptop's gpu is such a piece of crap that it doesn't support MSAA anyway, and my cpu does it instead. This is only an assumption (and we know a bit about assumption's family tree), so I'm open for suggestions. Anyway, for future reference, I hope this helps someone.

OH yeah, Solution: Switch to monogame. Monogame uses DirectX 11, which does support MSAA on MRT. Or of course only draw to a single render target, and then draw the same stuff to a different rendertarget all over again.

\$\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.