I want to change the texture of the model on button click and want that the normal map should not get disapper after i apply the texture or even after i change the texture of the model by button click.
plz can any one help me this is my pg https://playground.babylonjs.com/#SI13I2#34
in this if the texture is turned off then the nornal map is visible
1 Like
Hello @Ashish_Abhiwan , how are you doing?
By looking at you example I can see that you are creating a new material every time the user clicks on the buttons. If you wish to keep the normal map can you just reassign the albedo texture? Is that what you are trying to accomplish?
yeah, can you plz do that in the pg and explain it
@Ashish_Abhiwan , I did a bit of a refactor on your code.
Now I create the material outside the buttons click event and I assign it to the meshes. When the buttons onPointerUpObservable events I just reassign the albedo texture.
Bag configrator | Babylon.js Playground (babylonjs.com)
Is this what you had in mind?
but the normal map is displaced and i dont want the normal map to get displaed
The normal map seems to be displaced in your original PG as well. Maybe we are not applying it properly to the model. How was this normal map generated? Is it properly wrapped to this models UVs?
but when we import teh model the normal map that get imported with the model is accurate and propper if we apply that through script that gets displaced. is it possible that we can keep the mormal map that get imported with the model and can change the texture
I see. It seems like you model already has the normal map embedded on it, so there is nor reason to reimport it. I changed the playground example to use the normal map from the model and assign it to the new material.
Bag configrator | Babylon.js Playground (babylonjs.com)