NME material not updating in the scene when being rebuild

Hi,

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.

Example 4:

I’m using Babylon version 7.23.0 in this example. I’ve tried version 6.49.0 as well and this still works properly.

…is this a bug or am i simply missing something?

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 :slight_smile:

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.

2 Likes

Thanks @RaananW, i’ll try to give it a spin :slight_smile:
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.

…so same question really: Am i missing something or is it buggy?
I do not code at all, so perhaps it is my expectation for the UX/UI that are off :sweat_smile:

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)?

FYI @Deltakosh

It does trigger a refresh then. The issue with the PBR node still remains though, since it can’t compile it i guess.

Can you give me a summary of the issue? :slight_smile:

Regarding this NME: Babylon.js Node Material Editor (babylonjs.com)

it does not compile because it is not complete:

Ok I know what the problem is:) (Yes I speak to myself :))

Fix incoming: Fix error handling with NME by deltakosh · Pull Request #15524 · BabylonJS/Babylon.js (github.com)

3 Likes

What was the issue?

Well because of the new way we load shaders on demand, the build error was not correctly captured by the console (hence why it was working with 6.49)

My PR will reconnect the console correctly!

Sorry for the inconvenience