1

First, some context :

  • The 3D engine I wrote for my game allows me to switch between DirectX 9 and OpenGL, thanks to an intermediate API layer.

  • Both allow the user to enable multisampling (via GL_ARB_multisample for OpenGL, D3DMULTISAMPLE_x_SAMPLES for DirectX). Multisampling is enabled for the game window buffer.

  • The models for my characters use one big texture with texture atlases, so I disabled mipmapping there in order to avoid texture bleeding.

I experience the following results :

  • As I should, I get the same result when disabling multi-sampling for DirectX or OpenGL.

  • As I should, I correctly get edge smoothing on polygons when enabling multi-sampling for both.

  • However, in OpenGL, it seems that multi-sampling also has an effect akin to texture filtering, probably multi-sampling at different spots in the texture for each pixel, as the results are comparable to what mipmap would achieve, without texture bleeding - obviously, great. On the other hand, however, DirectX doesn't seem to provide this benefit as the result of texture mapping isn't anti-aliased, and the same as when multi-sampling is disabled.

I would very much like to know if there is anything I can do in order to get the same result in DirectX as in OpenGL. Maybe I am not aware of the good keywords, but I haven't been able to find documentation that relates to this specific aspect of multisampling.

genpfault
  • 51,148
  • 11
  • 85
  • 139
cleverfox
  • 11
  • 1
  • Sounds like on OpenGL you're getting super-sampling anti-aliasing (SSAA) rather than multi-sampling anti-aliasing (MSAA). Not sure why, perhaps the spec gives enough leeway for an implementation to use that technique, you may see different results with other graphics cards. While you might be happy with the visual quality of the SSAA, it can be significantly more expensive because the fragment shader has to run multiple times for each pixel. – Columbo Aug 31 '17 at 22:35
  • @Columbo And indeed, rendering takes about 30-40% more time with OpenGL than with DirectX, in that case. But that doesn't matter much because I have much leeway on recent hardware anyway. Any pointer as to how to achieve super-sampling with DirectX ? – cleverfox Sep 01 '17 at 05:26
  • There might be a more elegant approach offered by the API, but you could brute force it by creating a larger render target (e.g. if screen res is 1920x1080 then use 3840x2160), render your 3D scene to that, then copy from the larger render target to the back buffer before doing 2D elements. However, I would recommend persisting with MSAA and looking into other methods to fix the texture bleeding on your models so that you can reenable mipmapping (e.g. add padding to the atlas, use anisotropic filtering, use mipmap bias, set limits on the min mipmap level). – Columbo Sep 01 '17 at 06:33
  • @Columbo I agree and I would prefer to re-enable mipmapping if only for users whose software won't allow enabling MSAA. The texture is 2048x2048 and already padded with 16px, can't go higher. I tried limiting the min mipmap level but couldn't get it to work as there would be no visual change even when allowing only one level (!). I'll try to look into anisotropic filtering and mipmap bias as well. Thanks – cleverfox Sep 01 '17 at 09:37

0 Answers0