Node Material Editor - how do I get PBRMaterial albedo color?

I’ve been following a bunch of the NME tutorial videos on the Babylon youtube channel, they’re great!

I’m trying to get the color of my models (loaded from a glb file) to use as input into my shader that I’m creating on the Babylon NME. However, using mesh.color doesn’t work - my model is just completely black:

I’ve verified that the rest of my shader is working, and when I replace the mesh.color input with a manually set Color3 input, it works:

How can I get the albedo color of a PBRMaterial working in the NME?

Is your mesh having a vertex color ?

No vertex colors on the mesh currently, as we were relying on the albedo color on the material to render this model up until now.

Right, so mesh.colors relies on the vertex colors, understood. How would you recommend proceeding in our case, where we’re currently relying on the (uniform) albedo color of the material? Manually adding the vertex colors seems like duplicated work and prone to human error.

Another idea I can think of is to pass the albedo color as a vertex attribute input from code. This would probably work with Node Materials, but I’m not sure if it will work will the node material Editor?

I’m probably still lacking some fundamental knowledge in this area, so - sorry in advance if some of my questions/assumptions don’t quite make sense!

In the second screenshot where you’re using the input block named “test color” you could set it to the imported material’s albedo color like this for example. Note: the albedoColor is stored in linear space so I converted it to gamma space assuming that’s prob the color space you’re expecting it to be in when using it in your material. :slight_smile:

nodeMaterial.getBlockByName("test color").value = mesh.material.albedoColor.toGammaSpace();
mesh.material = nodeMaterial;
2 Likes