- Home /
Textures on procedurally generated mesh have lines in between
I just started on procedurally generated meshes and was going along great until I noticed this nagging problem that I really hope someone can shed some light on. I have a giant quad mesh made up of many little quads, and when I UV map some textures to these quads from a big tilesheet texture lines appear in between each of the little quads. The amount and intensity of the lines change when I change the Wrap Mode and Filter Mode of the tilesheet, though none of the options gets rid of them all, which is what I really want.
The tilesheet is here (only using the bottom left tile) and the UV mapping code is below:
for(i = 0;i < p.quadCount;i++) {
uv[0 + (i*4)] = new Vector2(0, 0);
uv[1 + (i*4)] = new Vector2(1.0/p.tileSheetX, 0);
uv[2 + (i*4)] = new Vector2(1.0/p.tileSheetX, 1.0/p.tileSheetY);
uv[3 + (i*4)] = new Vector2(0, 1.0/p.tileSheetY);
}
This for loop loops through every quad on the mesh and UV maps a section of the tilesheet to the four corners of every quad, with p.tileSheetX and p.tileSheetY being how many tiles are on the tilesheet (in this case p.tileSheetX = 8 and p.tileSheetY = 7). If I change this to the below:
for(i = 0;i < p.quadCount;i++) {
uv[0 + (i*4)] = new Vector2(0.01, 0.01);
uv[1 + (i*4)] = new Vector2(1.0/p.tileSheetX - 0.01, 0.01);
uv[2 + (i*4)] = new Vector2(1.0/p.tileSheetX - 0.01, 1.0/p.tileSheetY - 0.01);
uv[3 + (i*4)] = new Vector2(0.01, 1.0/p.tileSheetY - 0.01);
}
then there are no more lines unless you zoom very far out from the mesh, though if you go to 0.001 instead of 0.01 the lines reappear. This seems messy and doesn't appear very scalable for large tilesheets so I'd like a better fix.
Wrap - Clamp, Filter - Point
Wrap - Repeat, Filter - Point
Wrap - Clamp, Filter - Bilinear
Wrap - Repeat, Filter - Bilinear
I'm having the exact same problem with the same situation (giant mesh made of quads I UV from a tile sheet). If anyone has a clue please let us know!
It seems as if, at certain distances, the tile is shifting one pixel up/down and/or taking the color from a bordering tile.
Surround the tile with a bright color just outside the area the game should pickup, at least in my case that color is appearing at certain camera distances at the edge of the tile.
Update: $$anonymous$$y camera is set to zoom in and out with the mouse wheel, at orthographic sizes of 10 and 5 I get this issue. At 6,7,8,9 I see no lines at all!
Answer by sparkzbarca · Dec 30, 2013 at 10:09 PM
this has to do with mipmapping and antialiasing and stuff, basically there are times the graphics engine will sample the textures border (the white part) to determine an "average" value for texture scaling and antialaising and stuff and you end up with white getting thrown in which screws up the texture color value. The solution is well known.
all textures need whats called padding. Around the edge of the texture you take the texture edge color and yuo just drop it in.
you'd put a nice black border around that blue thing with a black edge and a generally brown texture around that water thing. You dont mark this part as part of the texture.
what you do is you make this padding border on a seperate layer and alpha it out. That way its not seen and is only sampled from.
The other alternative is to "extrude" the edge of the texture.
http://wiki.polycount.com/EdgePadding
this link will help you better understand if needed.
Your answer
Follow this Question
Related Questions
Texture atlas's, how to make them 2 Answers
Terrain Procedural Texturing based on height? 4 Answers
Same material, different meshes, different tiling 2 Answers
Realtime mesh deformation or texturing 0 Answers