Vertex Colors in Node Material Editor

Is it possible to assign more then one group of vertex colors to a model and get access to the data through the NME?

The idea is to store e.g. color information in one group of vertexcolors and e.g. store ambient occlusion in a second group.

If this feature doesnt exist , could it be implememented?

I am looking foward to your answer.

I’m not sure if I understand correctly, but you can pass custom data for each vertex of your mesh through the uv/uv2/uv3/… attribute.

When using the uv block in the node editor, you can change the attribute:

image

You can pass vec2 values this way.

You can also use any custom attribute but at the expense of a little more work. See Using shaders exported from Node Material Editor - #5 by Evgeni_Popov

1 Like

Hi Evegeni,

first of all thanks for your fast answer! What i try do is store information in the vertex colors of the mesh.
E.g. in the moment i use the vertex color which i get in the NME through the mesh color node to drive values in the node material editor. teh easiest example would be to use on of teh color channels to store the power for a rimlight function at this place in the mesh. The question is: Blender allows me to have more than one group of vertexcolors assigned to a mesh, can i read this information from the glb file or babylon file which i have exported or am i limited to one of the vertexcolor groups.

I’m pretty sure you won’t be able to export this data in a .glb file because it is not supported by the file format.

Exporting to a .babylon file I’m not sure, but I would guess it does not work either as Babylon does not support multiple vertex colors. But @JCPalmer will know for sure as he created the Babylon exporter for Blender!

That the export of one vertexcolor worked fine. Its just the question if i can have several different vertex color attributes at the same time in a mesh.

You can have any number of vertex attributes (well, there’s a max limit because a vertex shader has a limit to the number of attributes it can handle), but Babylon only knows about a single vertex color. If you add additional attributes (color or any other custom attributes), you will have to add custom shader code to handle it. Or, if you are using a node material, you can use the link I provided earlier to create a custom attribute and use it in your graph.

Thanks Evgeni, that helped me a lot.

There was a time, before a .babylon file could be serialized by BJS itself, when the .babylon was defined by the code to load it. Now, anything that is not @serialized that is in the file, will be ignored by the import. This includes multiple sets of vertex color info.

btw, the opposite is not true. That being things not actually in Blender, like Iridescence for a PBR material, can be exported using custom properties. The Blender GLB exporter does not do this.


Also, the .babylon generated by Blender DOES make judicious use of carriage returns. Any geometry starts on a new line. It only writes 50 numbers per line, by default, but you could open a Blender generated .babylon in a text editor and just grab the vertex color data pretty easily.

If you export twice with a different set of colors, you could paste it into a .js file or anywhere.

Could you implement the possiblity to access several vertexcolor groups in the Node Material Editor?
If yes when could it get implemented?

Thanks a lot for your time!

Best Regards
Tom

It’s not in our plan to support multiple vertex colors, as it’s quite a specific case and it’s also possible to do it currently: see my post above to pass a custom attribute to the node material.

1 Like