Search code examples
c#unity-game-enginetexturesmeshuv-mapping

How to get rid of lines on edges of triangles in generated mesh?


I made a procedurally generated map, but I think I have some problem with uv's.

This is what problem looks like:

model with visible unwanted lines

This is what my code for uv's of one tile looks like:

Vector2 u = new Vector2((float)textureID / TextureCount, 0.0f);
UVs.Add(u + new Vector2(1.0f/ TextureCount, 1.0f));
UVs.Add(u + new Vector2(0.0f, 1.0f));
UVs.Add(u + new Vector2(1.0f / TextureCount, 0.0f));
UVs.Add(u);

Vertices of each tile are ordered top-right, top-left, bottom-right, bottom-left in vertex array.

This is what the texture I use for testing looks like(5 squares of color and 3 transparent ones):

texture for testing

I'm using unity and lines are not visible in editor, only in play mode.

How to get rid of those ugly lines I got there?


Solution

  • I turns out that when generating mipmaps colors bleed through. Adding some padding in atlas solves the problem http://wiki.polycount.com/wiki/Edge_padding