instanceColor
is actually the instance color, and color
is the vertex color.
The reason color
works as an instance color in the example is that the vertex color buffer is created with a registerInstancedBuffer("color", 4);
call, which creates an instance buffer for “color”. Before instanceColor
existed (feb 2022), this was the only way to have a per-instance color, and it was not possible to have an instance color + a vertex color at the same time.
To make the instance color work with thin instances, you have to use the instanceColor
attribute, because thinInstanceRegisterAttribute("color", 4)
will actually be translated to thinInstanceRegisterAttribute("instanceColor", 4)
(we did this to retain backward compatibility). So, overall, instanceColor
should always be used when you want to use a per-instance color, and you should register the buffer by calling registerInstancedBuffer("instanceColor", 4);
/ thinInstanceRegisterAttribute("instanceColor", 4)
.
Here is an example that shows how to create a custom attribute for use in the NME: