Can a Node material be updated dynamicly?

I have a use case where the number and type of input nodes need to change based on the user input. Specifically I am looking to add additional texture and multiply nodes. I was wondering, is there a way to add nodes to a Node Shader after it has been “built”. Or do I need to recompile a new Node Shader each time I need to update it?

Once built the node material can still be updated (by adding new nodes / removing some /etc.) but you will have to call build() again to compile the shader

Ah gotcha, that is kind of what I suspected. Thanks.

Before jumping in and giving this a shot I had a few quick followup questions I thought I would ask.

  1. If a node is connected to an input do I need to explicitly disconnect before connecting a new node to that same input?

  2. What is the correct way of disposing nodes?

For reference here is a very simple example of what I am trying to do.
Original Network:
New Network: