Material after merging meshes

Hi everybody,

I have two boxes with the same texture and i want to merge them. It seems that the scale for the two meshes are kept after the merging instead of applying the texture on the whole merged mesh.

Could you tell me how i can now apply the texture to avoid the difference of scales between the two meshes ?

Thanks for your answer.

Boris

Boris

Hello!

You’d have to UV unwrap the newly created mesh somehow: graphics - Automatically generating UV coordinates algorithms - Stack Overflow

3 Likes

And do you know how to do that using BJS ?

Doing that with BJS would be the same as doing it in any other graphics engine or programming language, it’s a matter of implementing the algorithms and then updating the UV buffer accordingly: Updating Vertices | Babylon.js Documentation (babylonjs.com)

EDIT: here’s a very simple example using the spherical coordinates wrapping: Unwrapped merged mesh | Babylon.js Playground (babylonjs.com)
It’s worth noting that, depending on the chosen algorithm, even when the coordinates are unwrapped, there’s still going to be a noticeable change in the sections, since one of the boxes is much smaller than the other, there’s going to be more vertices in a smaller area.

Sorry, i’m really a beginner in this domain. I really thank you for your help

If I draw the resulting mesh with a wireframe material, that’s what I obtain :

In this particular case, (merging of two boxes), wouldn’t it be easier to remove all the facets and vertices that are common to the two boxes after merging them. So i assume that the 2 boxes would become a single one on which I could apply my texture without any problems.

Am I wrong ?

it would not as this would lose any information like UVs or Colors if any that may change between the boxes :slight_smile:

I think in this case, since @bvaisman wants to apply only one material to the entire mesh, it wouldn’t matter losing information between different meshes :thinking: So yeah, eliminating common vertices would also work in this specific case of the boxes.

It is impossible to know or infer how to auto UV the resulting shape after the merge unfortunately.