Let’s say I have a simple TSL node like this:
const goGreen = tsl.uniform(0);
const myTslNode = tsl.Fn(() => {
const n = tsl.vec4().toVar();
tsl.If(goGreen.equal(1), () => {
n.assign(tsl.vec4(0, 1, 0, 1));
}).Else(() => {
n.assign(tsl.vec4(1, 0, 0, 1));
});
return n;
})();
My question is, how can I make myTslNode reusable in multiple different materials? Right now, if I try to use myTslNode in multiple materials, then every time I update the goGreen uniform’s value (for example goGreen.value = 0), it will update it for all the materials I am using goGreen in. I would like the goGreen uniform to be material-specific, not global.
This way, I don’t have to duplicate the same node for every material I use it in.
Theoretically this could be supported, if I could create a “uniform of a uniform”. Instead of directly providing myTslNode with the goGreen node, we would provide it with a uniform that resolves to another uniform, where each “inner” uniform would be the material-specific uniform that resolves to 1 or 0.