Coming from Blender and its Shader Node system, I’ve recently been playing around with Babylon NME to test its capabilities.
However I’ve recently experienced that the materials simply does not show on the assigned mesh, even though the NME console states the material to be build successfully. In addition, i can get a “Node material build successful” message in situations where it previously would not (and probably should not. See example 4).
A very basic version can be recreated in a default playground with very few steps:
1: Add a new node material and assign it to the sphere
2: Add a new node, i.e. a similar Color4 node and plug it into the rgba slot on the FragmentOutput node. The console states to be missing both a Vertex and Fragment output?
3: Plug the original color4 node into the Fragment output node. Now the console states to have build the material successfully, but nothing shows in the scene anymore.
I have to admit that I was not aware of the fact that you can add a new NME directly from the inspector!! Nice work whoever added it
However, this is not entirely how the sync between the NME and inspector/playground works. To get the sync working you will need to add the material using code (snippet or json) to the playground. This way saving will also work (if you make any changes and save to a new snippet). So here - Using a node material for particles | Babylon.js Playground (babylonjs.com) you are able to edit the snippet because of this piece of code:
// this is the most important line
BABYLON.NodeMaterial.ParseFromSnippetAsync("#X3PJMQ", scene).then((nodeMaterial) => {
nodeMaterial.createEffectForParticles(particleSystem);
// not needed, but nice to have :-)
scene.debugLayer.show({ showExplorer: true, embedMode: true }).then(() => {
scene.debugLayer.select(nodeMaterial, "INPUTS");
});
});
If you want to addd an NME, create it, save it, add it as a snippet, and then you will be able to edit it and save a new version of it sidrectly in the PG.
Thanks @RaananW, i’ll try to give it a spin
Regardless of the sync with the playground, the behavior within the NME alone seems odd to me. The preview breaks after i get a compile error (obviously), but does not refresh when i’ve changed the nodes back to something that should compile easily.
In this case with the colors: If i remove the link between the grey Color4 node and FragmentOutput, i get the compile error as expected. When i attach the red Color4 afterwards, it seems to compile properly, but the preview remains grey (top picture). However, if i save the file as an URL it refreshes properly.
This is not the case for the PBR node though. Babylon.js Node Material Editor Is portrayed in the top picture here. I would expect errors here, since i haven’t provided any input values for the PBR node, correct? The console states it to be build, but the preview clearly struggles to know what to display. The second picture is the same build but in Babylon 6.49.
Yeah, I see what you mean. There seems to be a missing compile step. Can you try something for me? Do you get the expected behavior after switching the shape (for example from cube to cylinder and back to cube)?