I have created a 3d procedural mesh in 16x128x16 size separated in cubes. All the cubes share the same vertices with neighbor cubes. So I wonder if its possible to work UV faces while having merged vertices to attach textures to cubes. I read on the forum that it can be very hard or even impossible. So is there any way to make this done?
I’m not sure where in this series but here’s where I learned how to generate and texture procedural voxel chunks.
Not sure if I understand correctly, but you will not get merged vertices if you have flat normals = sharp edges as you have to break vertices for that.
I mean for example for 2x2x2 grid I have 17 vertices instead of 64 because I only create one vertice on each position. but when I create UvFaces I have the array of UV length of 64. But unity needs that Uv and vertices array are equal in length. So I need to solve this problem
It would seem to me you need a way to calculate how many faces you’re combining into one. Personally what I would do is while you are creating the faces take not of it’s size in each direction and the blocks at each place. Then when creating a uv combine the textures in the right positions and then draw to the face. What you’re doing is a " greedy" mesh generation right? I think that’s what it’s called. Google Greedy Voxel Generation would be a good place to start. For example I found this github which I think has what you’re looking for in it somewhere. Heads up it’s in java but it should be enough to get the idea across, even if you can only read C#. https://github.com/roboleary/GreedyMesh
Without code we can not guess how you generate UVs and meshes.
Another point to consider is that when you want merged vertecies your UVs must be continuous as well. So you can not assign values between 0 and 1 for each face. For a simple 2x2 grid the last vertex would have UV 2,2.
This seems to be impossible with a 3D grid anyway, especially if you generate it by code and not by hand.
Can you at least show us an image of the result?