I'm making a voxel game in XNA, and have filthy visual artifacts on long distances.

I use 2048*2048 atlases.

I'm already using mipmaps and 16x anisotropic filtering.

I've read this blog post, but I'm not quite sure that this is the problem.

This is how it looks like: Angle enter image description here


The atlas I'm using looks like this:


The topmost left square is used on the screenshots. I'm using XNA Content Processor mipmap compiler to generate mipmaps.

Every cube on the screen is separate, there is no gigantic cubes.

Does anybody have a clue what might it be?

  • 1
    \$\begingroup\$ i dont know how you have made your grid, but in the distance it will create thees artifacts. due to the same reason for why you use mipmaps. \$\endgroup\$
    – Tordin
    Commented Jul 17, 2013 at 8:11
  • 2
    \$\begingroup\$ Yes, can you tell us about the geometry. It is 1 or a few big squares with repeating textures, or is each square we see a separate square? Can you show us the exact texture you use. At first glance it looks like your mipmap generation might be screwed. But it's hard to tell. \$\endgroup\$
    – DaleyPaley
    Commented Jul 17, 2013 at 8:57
  • 1
    \$\begingroup\$ The standard way of generating mipmaps is to average 4 texels for each subsequent layer. The problem with atlases is that the tiles begin to bleed into each other at lower levels. That might be what's causing it. You may have to pad your tiles, modify the UVs like I suggested, or write your own mipmap generation routine to take the atlas into account. \$\endgroup\$
    – DaleyPaley
    Commented Jul 17, 2013 at 9:24
  • 1
    \$\begingroup\$ @DanielExcinsky No, what you are doing is shifting the whole tile by half a texel to the right and down, which will make things worse as the lower right edge with intrude more into adjacent tile. It really should be done in the generation of the UVs: minuv += halftexel; maxuv -= halftexel (for each quad). But anyway, you still might get problems with mipmapping (see my comment above) \$\endgroup\$
    – DaleyPaley
    Commented Jul 17, 2013 at 9:27
  • 1
    \$\begingroup\$ @DanielExcinsky If you look here: opengl.org/sdk/docs/man/xhtml/glTexParameter.xml you can find some mipmap level controls: GL_TEXTURE_MIN_LOD, GL_TEXTURE_MAX_LOD, GL_TEXTURE_MAX_LEVEL, GL_TEXTURE_LOD_BIAS, etc. Maybe playing around with those could help too \$\endgroup\$
    – DaleyPaley
    Commented Jul 17, 2013 at 9:30

1 Answer 1


This problem happens because you're mixing atlasing with mipmapping. Don't (naively) do this.

I've previously explained it in here, and with more detail in here.

In most cases, you either mipmap, or you atlas. For your case, you most likely want to mipmap instead of atlasing (which is most useful in 2D, not 3D)

If you must atlas, then be prepared to build your mipmaps manually, and do filtering and wrapping manually like it's explained on the article you showed.

  • \$\begingroup\$ Thank you! Actually, DaleyPaleys suggestions in comments and your answer here already have lessened the problem, but it still exists. I absolutely have to use atlases, so I will continue trying. I haven't yet tried wrapping each texture in atlas in 1px border, and the solution in the 0fps blog post. \$\endgroup\$
    – Dan Ganiev
    Commented Jul 17, 2013 at 13:29
  • \$\begingroup\$ And, one more problem I have, is that in Direct3d 9 Sampler type there is no such thing as MinLOD, which could've helped a lot, I think. \$\endgroup\$
    – Dan Ganiev
    Commented Jul 17, 2013 at 13:36
  • \$\begingroup\$ @DanielExcinsky: Why do you absolutely have to use atlases? Is this some kind of homework assignment? \$\endgroup\$ Commented Jul 17, 2013 at 14:34
  • \$\begingroup\$ No, I have an option for players to draw texture for cube side, texture size is 32x32. So if they drew, say, 2000 textures, I think it would be incovenient to send to GPU 2000 textures 60 times per second, so I pack textures into the bunch of atlases and send them to GPU instead. But maybe I am wrong, actually I haven't tried it in practice. \$\endgroup\$
    – Dan Ganiev
    Commented Jul 17, 2013 at 17:10
  • 1
    \$\begingroup\$ You don't send all the textures to the gpu each frame.And even if you did, there's hardly a difference between sending one large one and many small ones, as the amount of information you're sending is quite the same. What you will be saving is in render state changes, but even if you're drawing all 2000 textures every frame, I think modern gpus can handle it without a sweat. Do not "optimize" before even knowing if it is actually going to be an improvement, and that means profiling. The world well be a better place once everybody understands that most "optimizations" are actually unnecessary. \$\endgroup\$ Commented Jul 18, 2013 at 2:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .