Node Material Editor has customizable inputs. But I can’t understand how to control them from the scene? Unfortunately I did not find the answer in the existing video tutorials and forum topics. I assumed that they can be used as attributes of a material, after a dot. But that doesn’t work like that. I would really appreciate it if anyone could share an example. Thanks!
Hey @Steff
Thanks for asking about this! It’s in the documentation, but it’s a little hard to find.
This is the section you’re looking for: How To use the Node Material - Babylon.js Documentation
Specifically, this is the part I think you’re after:
let block = nodeMaterial.getInputBlockByPredicate((b) => b.name === “foo”);
block.value = 10;
There are different types of nodes so accessing the inputs for different nodes in your code is different per node. For example, if you want to change the texture of a texture node it looks like this:
let block = nodeMaterial.getBlockByPredicate((b) => b.name === "foo");
block.texture = *your texture*;
I hope this helps and answers you question.
Thank you so much for such a quick response! This community is amazing
I just want to add that it is worth paying attention to the name of the InputBlocks. It drove me crazy that the node with the name “position” just didn’t work properly, after much revision in the code, it turned out that it was all because of the name : )
P.S. But what I also want to note is the incredible performance of instances in conjunction with vertex shaders. I would never have thought that 1200 objects can have unique deformations with almost no loss of fps on an average phone. You guys really did a great job!