Register Instanced Buffer turns mesh instance black

I made instances of a cube and I’m trying to use registerInstancedBuffer to allow me to change the color of certain instances of it during gameplay.
It seems to work just fine on primitive objects created with babylon, however when I import my own mesh that I made in blender simply using registerInstancedBuffer on it will turn the mesh completely black.
The mesh I made is exported from blender as .glb and is rather simple.
I also tried it with the default cube that comes when you make a new scene but it still shows the same issue.

When I use some of the meshes provided by babylon in the playground however it works just fine.
They all seem to be .Babylon files though, so that might be related?

Here’s the playground showing the issue:

I believe @Drigax worked on related things.


On it

Ok this one is interesting :slight_smile:

When you instanciate a gltf object, you need to make sure they are either under the same parent or you need to remove the parent from the root node

This is because every gltf file comes from a right handed world. To get it into left handed world, we are adding an arbitrary parent that is adding a negative scale on z

Here is the solution:

Note: I updated the instances doc to mention that point


Thank you @Cedric @Deltakosh :smiley:

Perfect solution for the issue!

As a followup question:
Is there a document somewhere saying which different properties of a mesh you can change through instanced buffers?
In the examples I can find it always uses color only, but are there also other things you can change per instance such as emmissive color for example?

Also thanks for updating the documentation.
Wanna point out that there’s a small typo and it says source.setpParent(null) instead of source.setParent(null).

Thanks for the typo :slight_smile:

You can instantiate any attributes supported by the shaders (typically: color, uv, uv2, etc…)

If you create your own shader with ShaderMaterial it could be anything declared as an attribute

1 Like