Error applying a node material. 'updateFlag' of undefined

Hey all,
I am probably missing something obvious, but I am working on a scene where I have created a simple node shader and am storing it with the rest of the scene materials. However when I try and apply it like “object.material = nodeMaterial” I get an error “Cannot read property ‘updateFlag’ of undefined”

Any help pointing me in the right direction as to what might cause this would be super helpful.

Hi @CanvasGadget - Have you already looked into those Node Material [examples] in the documentation (Node Material | Babylon.js Documentation)? At the top of this page, there are different playgrounds with node materials so you can see how to use them.

Otherwise, could you share a playground with your node material so maybe @PatrickRyan can see how to help you?

1 Like

Thanks @thomlucc after playing with it for a while I was able to get it to work. Since I had just copied and pasted from the editor I had failed to notice that the hosting scene was not included in my constructor.

Example:
var nodeMaterial = new NodeMaterial(“shaderName”); - This Failed
var nodeMaterial = new NodeMaterial(“shaderName”, scene); - This Worked

2 Likes