How can I access NodeMaterial input values in the code

Hello !

I am trying to add some custom shaders to my scene. I used the node material editor, and it looks good. I made it so that some node values are visible in the inspector. But I would like to be able to edit these values in the code.
Specifically, I would like to use my shader on several meshes, but with different input values for color, glossiness, etc.

I’ve been looking for a way, but it seems that once the node snippet is parsed, the input values are nowhere to be found on the material object.

To reproduce, I used a playground I found with some other shader. The goal would be to change the shield color in the code (here I try to make it blue on line 23), just like I would do by changing the value in the inspector.

Did I miss something obvious ? Is it just not possible ?

Example -

Basically, one needs to have a look at the Node material to see available Input blocks with their corresponding names.

Then get block by name and change its value accordingly.


Ooh, right, I couldn’t put my finger on the getBlockByName() method.
Thanks a bunch ! :slight_smile:

1 Like