Coffee Boat
Coffee Boat

Reputation: 749

Seams on edges of voxel chunk meshes

I'm currently working on voxel terrain generation in Unity, and I've run into something annoying:

From certain camera angles, you can see seams between the edges of chunk meshes, as pictured below:

enter image description here

What I know:

  1. This only occurs on the edge between two meshes.
  2. This is not being caused by texture bleeding (The textures are solid colors, so I'm using a very large amount of padding when setting up the UVs).
  3. The positions of all vertices and meshes are showing up as exact integers.
  4. Disabling anti-aliasing almost entirely fixes this (You can still see the occasional speck along the edge).
  5. I'm using Unity's default Standard shader.

Can someone explain what's causing this, and whether there's a way to solve this other than disabling AA?

Upvotes: 0

Views: 2004

Answers (1)

Tommy
Tommy

Reputation: 100632

Almost certainly the side faces are demonstrating z-buffer fighting with the top faces — precision is imperfect so along the seam of your geometry rounding errors are making the very top of the brown face of one cube seem to be closer to the camera than the very top of the green face of the next.

Ideally, don't draw the brown faces that definitely aren't visible — if a cube has a neighbour on face X then don't draw either its face X or its neighbour's adjoining face.

Upvotes: 1

Related Questions