I'm working on a graphics engine that lets you walk around a world that is made up of cubes (voxel engine) and I'm having some difficulties getting the results I want.

I'm not the best at 3D graphics, but I'm willing to learn. When I have anti-aliasing turned off, the textures line up properly together on the surfaces, but when I turn it on, I see a lot of lines between each square face. I've taken a picture:


I've tried changing the mip map mag filter options on the sampler, but cannot get it to look right. I've tried increasing the quality of the textures, but that doesn't help either. When I use Linear TextureFilter but that just makes everything super blurry, and the edges are even more obvious. In fact many edges get some blurry white and dark color to them. Anisotropic doesn't help.

Nothing I do seems to get rid of those lines in between faces when I have AA turned on. Anyone have any advice on where I would start looking? I'm assuming it's because all of the faces are individual, and not mixed together when they are next to each-other. Not just the edges are being anti-aliased. Not sure if I'm even on the right track with that thought.

I'm using XNA 4.0 to do this.


1 Answer 1


Without seeing any code it's hard to guess, but here are two three major pitfalls to look out for:

  1. On 3D graphics hardware, the edges of adjacent polygons are only guaranteed to align 100% if their vertices are 100% the same. So if you generate the vertices for each cube individually, and you use an algoritm that introduces tiny floating point errors... *boom* there could be tiny cracks all over the place at any time. Make sure to re-use vertices where possible, or at least re-use their exact floating point position.

  2. Are the textures used for each cube subtextures? In that case, try setting the AddresU/AddressV TextureAddressMode to Clamp.

  3. Are the textures used for each cube subtextures? Do the u,v coordinates match the exact corners of the subtexture without any additional padding? In that case, mipmapping is biting you. Especially the further-away tiles are sampled from the 2x downscaled mipmap, so your neatly fitting u,v coordinates now include part of the pixels from the adjacent area's (i.e. bleeding). As a quick test, assign a new sampler state and set

    state.Filter = TextureFilter.Point;

  • \$\begingroup\$ Thanks for replying! Yes the textures are for each cube subtexture, and i tried clamp, which cleaned up the lines a little bit, but not enough. Still have major lines especially in the distance. \$\endgroup\$ Mar 6, 2012 at 13:26
  • \$\begingroup\$ I'll verify vertex positions and come back to this answer. \$\endgroup\$ Mar 6, 2012 at 13:32
  • \$\begingroup\$ It doesn't seem to be the vertex positions. Mind you, the vertices are not literally the same, but their values are exact. One of the reasons it's easy to see, is because they are all whole numbers (it's all cube faces of size 1x1x1) any other ideas? It seems to be something with the texture perhaps? \$\endgroup\$ Mar 9, 2012 at 3:56
  • \$\begingroup\$ Ah, integer coordinates rules out floating point mismatches. Could you post your larger image? Oh shoot, brainwave, mipmapping. Updated answer. \$\endgroup\$
    – Paul-Jan
    Mar 9, 2012 at 19:14

You must log in to answer this question.

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