Hi
I prepared a startup PG for my question.
My question is:
Is there a way in NodeMaterial from the snippet in the PG, to change it in such a way, that one mesh will be blue and the other red? With one shader, based on the mesh, maybe name or something, but not based on the position (this I know and it did not fit my project?
And BTW congrats, version 5 wooohooo
Regards
Peter
You can clone the material and update one of the block by using getBlockByName
:
https://playground.babylonjs.com/#MRTBLQ#1
Note that I have renamed some of your blocks in the NME to be able to access them by name.
I’m doing it like that temporarily like this, but the material is compiling again or at least computed again and it hits performance.
That’s why I said, “With one shader”. I do not want to clone it, it’s too complex to clone it cause it has too big performance hit, unfortunately.
is there a different way? It does not have to be with Lerp or anything as long as it switch something in material. “If” would be good, but I know why you do not want to introduce it and it’s fine as long as there are alternatives.
Regards
Peter
If you want to use a single material you can try something like this:
https://playground.babylonjs.com/#MRTBLQ#3
1 Like
That looks super promising I will give it a go and let you know about the result today
Thanks
1 Like
It worked. I mess around with it a little and it actually did what was promised
Thank you for your help
Regards
Peter
1 Like