Hello Guest

MSAA Texturing Artifacts

  • 2 Replies
  • 382 Views
MSAA Texturing Artifacts
« on: November 03, 2018, 15:08:17 »
This occurs in a basic 3D voxel game I've been working on, if I enable MSAA in GLFW window hints.
I use a texture atlas, and each block face is made of two textured triangles, rather than fewer, more optimised, larger triangles.
I'm looking to be pointed in the right direction to solving this problem, and I'll provide any necessary information to get there. Thanks :D

*

Offline KaiHH

  • ***
  • 149
Re: MSAA Texturing Artifacts
« Reply #1 on: November 03, 2018, 15:25:32 »
If this happens only with multisampled rendering, then the issue is very likely that texture coordinates for pixel centered sample locations are sometimes extrapolated when they do not lie inside the rasterized primitive.
Read this for an explanation: https://docs.microsoft.com/en-us/windows/desktop/direct3d11/d3d10-graphics-programming-guide-rasterizer-stage-rules#multisample-anti-aliasing-rasterization-rules
(it's for Direct3D, but the same applies for OpenGL).
To combat this, you can enable "centroid" vertex attribute interpolation for your texture coordinates.
See "centroid" in: https://www.khronos.org/opengl/wiki/Type_Qualifier_(GLSL)#Interpolation_qualifiers

Re: MSAA Texturing Artifacts
« Reply #2 on: November 03, 2018, 15:33:57 »
That's delightfully obscure and even more delightfully quick. Instant fix. Thanks!
Github repo here in case you were interested.