Change texture with certain UVs range

Hello everyone
I want to really change some texture with certain UVs range.
I’ve received the good solution from Carol, but as I am a beginner at this interesting babylon.js, I can’t confirm her opinion and I am still finding solution.
What I want to is the following.
“The scene obtained using SceneLoader.Append has some spheres with textures applied to them.
What I want to do is to replace a certain part of the sphere with a different texture given.
I want to change the small squares to a constant texture.”
Thank you

How do you describe/characterize the part you want to change? Is it based on uvs, so you would change the texture where umin < u < umax and vmin < v < vmax? Giving a uv range would probably work for a simple sphere because the uv mapping is uniform, but it would not work in general for other more complex mapping schemes.

Also, did you have a look at decals (Decals | Babylon.js Documentation)? It’s an easy way to project a texture onto an object.

4 Likes

In the future please refrain from opening multiple topics on the same subject, as this makes things messier :slight_smile:

Thanks for your solution.
Having a deep knowledge of babylon.js is commendable.
I think your opinion is correct considering the case that uv mapping is not unique.
Thanks a lot.

Hello Evgeni_Popov
I came to you while I was in trouble
As you taught, I used decal, but the sphere is not uniform, so I can’t get the correct decal position.
Could you possibly teach me?

You should do a ray picking to get the intersection point and the normal at this point.

See how it is done in the examples of this page:

1 Like