Each face of the cubes has its own vertices, so a neighboring face does not share any vertex. In this way, a different texture can be added to each face by specifying its UVs.
The problem I have is that I want to create each face of the mesh sharing its vertices between the faces, how would I have to do to add a different texture on two faces if they share their vertices?
Hello. I have not explained myself clearly enough, sorry. I know about the “mark seam” of blender, but I am generating the terrain in runtime, I create the mesh in runtime. So, I generate the terrain like this:
Each face of the cube is assigned its UVs because it has its own vertices. For example, vertices (1, 2, 3, 4) are assigned a UVs coordinate for grass, but (17, 18, 19, 20) a UVs coordinate for a dirt wall. Instead, if I create the terrain like this, sharing the vertices:
I can no longer assign the UVs to each face of the cube because they share the vertices. Or at least I don’t know how to do it, that’s what I’m asking, how can this be achieved.
Ok I’m sorry I misunderstood the question. I believe you can’t do it without duplicating the vertex.
As you know, each vertex gets assigned a Vector2 which is the coordinate in the texture which is a value from 0 to 1 for the U and V coordinates (0,0 for bottom left). Unless if you create a different UV coordinate (uv0, uv1) which is impractical for your use case, you can’t assign different UV values for each vertex. The texture for a single face in this case would also need to share coordinates but this is impractical for you too because not every face share coordinates.
UV coordinates map directly to Vertices. That’s just how it works in a Unity Mesh object.
They don’t on Unity. They might at a higher level with their own internal structures, but a translation has to be done to get it from whatever crazy structure they have down to the Unity Mesh structure.
The only other way would be to live-manipulate your textures, fabricating hybrid chunks of continuous textures that couple different patterns side by side. I can’t imagine this would be performant or easy to do in the general sense.
And how could I do that? Wouldn’t it thus be possible to generate a procedural terrain in runtime with different textures on each face but sharing the vertices?