# More vertices or more material instances?

I am creating walls programmatically. Each wall has a north, south, east, and west side, no top or bottom. There are 4 vertices per side, totaling 16. I want it to also assign a material to said wall, without stretching the texture, I just want it to repeat properly. So if the wall were say, 10.5 units long, and the texture covered one unit, the texture would be cut off by .75 units on each side without stretching. What method would be most efficient for doing this: Creating an instance of a material for every wall with tiling specific to that wall, or UV mapping and adding more vertices to each wall?

UV mapping, by far and away, will be more efficient. No need to add more vertices, and definitely don’t make a new material for each.

I think I was confused, I thought I needed to add more vertices in order to UV map properly. For some reason I thought they worked the same way as triangles. I’ll have to do some reading to implement them, thanks for your response!

EDIT: Actually I’m still a little confused, because the texture is stretched between vertices, so if there are only 4 vertices per side how would I make the texture repeat between those four?

Let’s say you have a wall that’s 1 unit wide and tall and want the texture to show exactly once, your UVs will be 0.0 to 1.0. If your wall is 2 units wide and 1 tall and you want the texture to repear twice, then just have the UVs go from 0.0 to 2.0 on the x, and 0.0 to 1.0 on y. Or -1 to 1.0, or 12 to 14, etc.

The easiest thing to do is apply the same values you would to your “custom material” scale & offset directly to the mesh UVs.

edit: Vertex positions are in 3D space, where UVs are in 2D texture space, and by default textures repeat.

Alright, I have it figured out now, even have it offset the way I like. Thanks for the help!