Texture UV in custom mesh

Hi, I have a question about textures and UVs. I have a terrain similar to this, Minecraft style:

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?

It is understood what I am asking?

Bump.

Help.

Deleted by author since info was unrelated to the question.

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:
6977534--823001--upload_2021-3-26_15-8-28.png
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:
6977534--823004--upload_2021-3-26_15-8-34.png
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.

Thank you for helping me.

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.

1 Like

But then how do other terrains (that share vertices) to be created in runtime and with different textures?

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.

1 Like

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?

Thanks for answering.

As long as both of those textures can be placed on the same Material.

1 Like

You mean this?

7025230--832120--upload_2021-4-10_20-36-45.png

That is, not that each face of the terrain has a texture, but rather that the terrain is an entire texture.