Node Material Editor - instance color

Hi,
Is instance color supported in node material editor?
I want to get instance color from instance buffers and pass it onto the fragment output

https://nodematerial-editor.babylonjs.com/#CAID22

Thanks
Gopinath Vellingiri

Vertex colors are exposed as mesh.color in the Nodematerial Editor. (Look under Mesh → Color)
https://nodematerial-editor.babylonjs.com/#CAID22#1

Hi @Raggar,
I am asking about Instance Color through instanced buffers not vertex color.
In Instance block, transformations are available but colors are not available.

Thanks
Gopinath Vellingiri

1 Like

But vertex colors Are part of the vertex buffer of the mesh(assigned to each vertex):

If you are looking to assign some other variable as an attribute, look at this:

3 Likes

In a typical CAD assembly, not all instances will have instance color.
Instances without instance color has to be rendered with mesh(vertex) color.

https://nme.babylonjs.com/#EPY8BV#96

In above NME sample, I have to choose mesh color if instance color is not available.
Usually Instance property includes Color and Transformations.
Currently NodeMaterial block ‘Instances’ doesnot have a InstanceColor output.
So, I am forced to Clone the mesh instead of instancing which increases number of meshes and draw calls,
thereby reducing performance.

If I use the below example, I dont have control which color gets applied to the mesh finally
https://playground.babylonjs.com/#HQ4P5G

I prefer a InstanceColor output from “Instances” NME block.
@Evgeni_Popov

Thanks

2 Likes

If you use the attribute named “color” for your instances, it will replace the regular “vertex color” attribute. What you can do is name your instance color something else, so that you can have both the vertex color and instance color attributes:

https://playground.babylonjs.com/#HQ4P5G#2

Use the setAsAttribute method of the input block to transform this input to an attribute.

2 Likes