Procedural Mesh - Lines Between Faces

Hi all,

I’ve created a tile based mesh through code, with each ‘tile’ being composed of it’s own 4 vertices / UVS etc. Nearly everything is running perfectly, apart from getting these weird lines displayed between the tiles.

Does anyone have any idea what they are, and if so, how the hell to get rid of them? We have tried playing around with all the texture import options, and the texture itself is pixel perfect. Pictures in the spoiler below.

Thanks in advance.

EDIT : More research, more info.

Have called .RecalculateNormals() but to no avail. The mesh does not share any vertices between tiles.

Am I right in saying the mesh needs to share normals? If so, how would I go about doing this?

Edit 2 : tried manually setting the normals. Absolutely no idea what I’m doing. Is it possible to just set them all to one shared value, as they’re all facing the same direction?

Thanks again.

Hate to bump but still struggling.

Have disabled mipmaps, which kinda helped. It removed the problem from the scene view, and when I did a build it was less noticeable, but still there when you zoom the camera in and out.

Anyone?

I have this problem with my voxel terrain and I solve it by setting texture as clamp.

Thanks for your response.

I’ve tried setting the Wrap mode to clamp (and repeat, just to see) and that unfortunately has had no effect. I think I’ve tried just about every texture import setting there is!

Bump.

Bump.

I had a problem like this and it took me a little to figure out… My issue was, I presume, due to floating point errors in the uv coordinates. The lines between tiles was actually the next section of the texture being included into the wrong tile.

So to clarify, I had a texture that I was using as a sprite sheet. This texture had a bunch of different tiles set out in a grid format and I would obtain the tiles texture based on a uv coordinate system. The way I fixed the lines was to slightly reduce the uv coordinates so the actual square box was smaller than the tile image.

For example:
lowerRightCornerUV.x = (uvCoordX * tileWidth) - 0.01f

Understand? So you are just subtracting a small value so the floating point precision error isn’t noticable… I had to play around a bit to find the magic numbers to subtract… If anyone has a different way, I’d be happy to hear it too though. FYI: that code is for demonstration purposes only.

I’m on my phone so I cannot format the code, sorry.

1 Like

I had lines on my mesh second time and now i fixed it by setting max texture size as 32.

Seems dodge, but thanks. It helped solve my problem.