How to make NME material for thin instances with color attribute?

Heya :slight_smile: I’m trying to use NME to make a material for a mesh with thin instances, but can’t get the color attribute to work.

Here’s a simple NME that uses the instances block and color attribute for example: NME Material

It works well with instances like here: Instances PG

But with thin instances, they’re drawn black like here: Thin Instances PG

The PG’s are simple ones from the documentation with just the material changed to the above NME material. And if you comment out lines 47 and 48 on the Thin Instances PG you can see the color attribute working with the default material.

Not sure if it worked before or if it’s even something that’s supposed to work? Or if not maybe there’s a workaround? :thinking:

PS I tried changing the attribute kind from “color” to “instanceColor” in case it’s related to that recent change but it didn’t help.

Update: I tried the Thin Instances PG with BJS version 4 and it did work then so seems to be a regression… Maybe @Evgeni_Popov can help? :slight_smile: :pray:

or maybe @sebavan ?

1 Like

So I did find a (temp :pray:) workaround from this demo of custom attributes, although it’s not as conventient since the connections to other blocks must be made in code rather than just using NME. :slight_smile:

The god of war weapon demos are broke in v5 too :frowning: :cry:

1 Like

So I did just find a simpler fix at least. Running the below code after loading the NME material seems to work to make the material compatible with the new thin instance attribute “instanceColor”.

const colorBlock = nodeMaterial.getBlockByName("color");

cc @sebavan / @cedric: I think we should add automatic support for instanceColor like we did in other materials

@jeremy-coleman:Which demo are you referring to? cc @PatrickRyan as I think this is your weapons demo

1 Like

Yes sorry shoulda linked a pg. It’s Patrick’s weapon demo here (unsure if its the original copy or a fork)

I just did a quick search for “daggerMagicActive” to find all the forks (7 total)

All are the same, except that this one. It gets passed the loading screen, although doesn’t work. It’s probably someone’s failed experiment, but could be useful to compare for debugging. Note: this is not the one that used to work!!

I also noticed patrick’s music vizualizer is broken too! :crying_cat_face: :ocean: :swimming_man:

Ohhhhhh this is not related but I ll fix both Demos ASAP

I will also submit a fix for the instanceColor by adding an extra attribute in NME to differentiate from the vertex colors.

Music visualizer: (a couple new where not in the right place)

Next :slight_smile:


Ok got the one for the god of war demo and it is related to some of our latest tangents changes moving from vec3 to vec4. I ll push a back compat fix for it tomorrow with the instanceColor one :slight_smile:


Both will be fixed by Pull requests · BabylonJS/Babylon.js · GitHub @Blake you ll need to use the instanceColor attribute instead.


I tried the test build for the PR but couldn’t get it working (tried changing the name from “color” to
“instanceColor” but didn’t help). It looks like the changes to serialization are for the other issue so saving from the live NME with the old serialization code should work for testing the color fix right? Thanks! :slight_smile:

1 Like

Here is the fix live: Thin instances simple example | Babylon.js Playground (


Aah it uses a different block than instances now, ok thanks! :beers: