MSAA Texturing Artifacts

Started by Screendead, November 03, 2018, 15:08:17

Previous topic - Next topic

Screendead

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

KaiHH

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

Screendead

That's delightfully obscure and even more delightfully quick. Instant fix. Thanks!
Github repo here in case you were interested.