# Node material and instances

**URL:** <https://forum.babylonjs.com/t/node-material-and-instances/28447>\
**Category:** Questions\
**Created:** [March 15, 2022, 2:24pm UTC](https://forum.babylonjs.com/t/node-material-and-instances/28447 "2022-03-15T14:24:01Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![samevision](https://avatars.discourse-cdn.com/v4/letter/s/73ab20/32.png) [@samevision](https://forum.babylonjs.com/u/samevision)\
**Post date:** [March 15, 2022, 2:24pm UTC](https://forum.babylonjs.com/t/node-material-and-instances/28447/1 "2022-03-15T14:24:01Z")

</div>

Hello guys,

I have a scene where I load a mesh via asset container to make use of instantiateModelsToScene(). Unfortunately I encountered a problem here. I want to use the same node material for all the instantiated meshes. But this leads break the functionality of separated animations.

Even though I added the instances block to my node material: [https://playground.babylonjs.com/#8RJEY8#7](https://playground.babylonjs.com/#8RJEY8#7)

Any idea what I am doing wrong?

Best

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [March 15, 2022, 6:16pm UTC](https://forum.babylonjs.com/t/node-material-and-instances/28447/2 "2022-03-15T18:16:26Z")

</div>

I don’t think this is related to instances, because it happens for single meshes too, with any node material: [Available Mesh BrainStem | Babylon.js Playground (babylonjs.com)](https://playground.babylonjs.com/#J62R3F#74). Probably related to skinning? I’ll have to ping @bghgary again for that 🤣

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [March 15, 2022, 6:18pm UTC](https://forum.babylonjs.com/t/node-material-and-instances/28447/3 "2022-03-15T18:18:25Z")

</div>

Oooh, you’ll have to add the bones in the material for it to work: [Node Materials and animated meshes. (4.1) - Questions - Babylon.js (babylonjs.com)](https://forum.babylonjs.com/t/node-materials-and-animated-meshes-4-1/11082)

---

<div class="post-metadata">

**Author:** ![slin](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/slin/32/36084_2.png) [@slin](https://forum.babylonjs.com/u/slin)\
**Post date:** [March 15, 2022, 6:18pm UTC](https://forum.babylonjs.com/t/node-material-and-instances/28447/4 "2022-03-15T18:18:28Z")

</div>

Hi @samevision

Like this? [https://playground.babylonjs.com/#8RJEY8#10](https://playground.babylonjs.com/#8RJEY8#10). The problem is the cloned animation groups for eyes are not started. I manually triggered play and it worked. The rest of the mesh were actually started, but you didn’t set a different position so their anim are overlapped with the original model.

@carolhmj is correct. instantiateModelsToScene is cloning, not instancing.

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [March 15, 2022, 6:30pm UTC](https://forum.babylonjs.com/t/node-material-and-instances/28447/5 "2022-03-15T18:30:18Z")

</div>

Yep adding the proper bone nodes solves the issue, there’s already an example on the linked question but here’s a simpler one: [Babylon.js Node Material Editor (babylonjs.com)](https://nme.babylonjs.com/#KBV970#8)  
[Available Mesh BrainStem | Babylon.js Playground (babylonjs.com)](https://playground.babylonjs.com/#J62R3F#76)

---

<div class="post-metadata">

**Author:** ![bghgary](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bghgary/32/48532_2.png) [@bghgary](https://forum.babylonjs.com/u/bghgary)\
**Post date:** [March 15, 2022, 6:59pm UTC](https://forum.babylonjs.com/t/node-material-and-instances/28447/6 "2022-03-15T18:59:03Z")

</div>

> [@slin](#):
>
> instantiateModelsToScene is cloning, not instancing.

This function will instance when possible or clone otherwise.

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [March 15, 2022, 7:40pm UTC](https://forum.babylonjs.com/t/node-material-and-instances/28447/7 "2022-03-15T19:40:12Z")

</div>

Despite adding all of it, there is still smthg wrong with the eyes [https://playground.babylonjs.com/#8RJEY8#13](https://playground.babylonjs.com/#8RJEY8#13)

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [March 15, 2022, 7:59pm UTC](https://forum.babylonjs.com/t/node-material-and-instances/28447/8 "2022-03-15T19:59:42Z")

</div>

Assigned @carolhmj on March 15, 2022, 7:59pm UTC



---

<div class="post-metadata">

**Author:** ![samevision](https://avatars.discourse-cdn.com/v4/letter/s/73ab20/32.png) [@samevision](https://forum.babylonjs.com/u/samevision)\
**Post date:** [March 15, 2022, 10:00pm UTC](https://forum.babylonjs.com/t/node-material-and-instances/28447/9 "2022-03-15T22:00:01Z")

</div>

> [@carolhmj](#):
>
> Oooh, you’ll have to add the bones in the material for it to work: [Node Materials and animated meshes. (4.1) - Questions - Babylon.js (babylonjs.com)](https://forum.babylonjs.com/t/node-materials-and-animated-meshes-4-1/11082)

But I added the bones block already - not working ☹: [https://nme.babylonjs.com/#V3R0KJ#31](https://nme.babylonjs.com/#V3R0KJ#31)

> [@slin](#):
>
> Like this? [https://playground.babylonjs.com/#8RJEY8#10](https://playground.babylonjs.com/#8RJEY8#10)

The eyes are not my problem here. My problem is that with node material the animation are played synchronously. But I want to be able to play them separately.

With node material: [https://playground.babylonjs.com/#8RJEY8#15](https://playground.babylonjs.com/#8RJEY8#15)

Without node material: [https://playground.babylonjs.com/#8RJEY8#16](https://playground.babylonjs.com/#8RJEY8#16)

As you can see without node material the animations are separated. They second one has a delay of one second due to the timeout.

---

<div class="post-metadata">

**Author:** ![samevision](https://avatars.discourse-cdn.com/v4/letter/s/73ab20/32.png) [@samevision](https://forum.babylonjs.com/u/samevision)\
**Post date:** [March 15, 2022, 10:08pm UTC](https://forum.babylonjs.com/t/node-material-and-instances/28447/10 "2022-03-15T22:08:57Z")

</div>

It seems that the missing morph target block caused this problem. It’s working now 🙂 : [https://playground.babylonjs.com/#8RJEY8#17](https://playground.babylonjs.com/#8RJEY8#17)

The eyes are still broken.

---

<div class="post-metadata">

**Author:** ![samevision](https://avatars.discourse-cdn.com/v4/letter/s/73ab20/32.png) [@samevision](https://forum.babylonjs.com/u/samevision)\
**Post date:** [March 16, 2022, 10:58am UTC](https://forum.babylonjs.com/t/node-material-and-instances/28447/11 "2022-03-16T10:58:50Z")

</div>

Ohhhh ☹

It was too early. It is working with the alien model but I noticed that my model is still not working properly.

Alien - this is how it should look like (animations can be played independently): [https://playground.babylonjs.com/#8RJEY8#19](https://playground.babylonjs.com/#8RJEY8#19)

My model - animations are running synchronously (if you check the animation groups at inspector you will see that the first animation group animates both meshes and the second one does nothing): [https://playground.babylonjs.com/#8RJEY8#18](https://playground.babylonjs.com/#8RJEY8#18)

What’s wrong with my model or node material?

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [March 16, 2022, 3:56pm UTC](https://forum.babylonjs.com/t/node-material-and-instances/28447/12 "2022-03-16T15:56:54Z")

</div>

Eyes will be fixed by [NME Fixes by sebavan · Pull Request #12172 · BabylonJS/Babylon.js · GitHub](https://github.com/BabylonJS/Babylon.js/pull/12172) You ll be able to try out on your other models as soon as it as shipped.

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [March 16, 2022, 5:45pm UTC](https://forum.babylonjs.com/t/node-material-and-instances/28447/13 "2022-03-16T17:45:57Z")

</div>

Unassigned @carolhmj on March 16, 2022, 5:45pm UTC



---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [April 14, 2022, 10:29am UTC](https://forum.babylonjs.com/t/node-material-and-instances/28447/14 "2022-04-14T10:29:46Z")

</div>

Hey there @samevision have you had a chance to try out the fix, did it work for you? 😃

---

<div class="post-metadata">

**Author:** ![samevision](https://avatars.discourse-cdn.com/v4/letter/s/73ab20/32.png) [@samevision](https://forum.babylonjs.com/u/samevision)\
**Post date:** [April 14, 2022, 1:05pm UTC](https://forum.babylonjs.com/t/node-material-and-instances/28447/15 "2022-04-14T13:05:32Z")

</div>

Hey @carolhmj,

I tested it in my local project and it seems to work now 🙂
