# Sandbox material binding problem

**URL:** <https://forum.babylonjs.com/t/sandbox-material-binding-problem/14951>\
**Category:** Bugs\
**Tags:** material\
**Created:** [October 16, 2020, 2:38am UTC](https://forum.babylonjs.com/t/sandbox-material-binding-problem/14951 "2020-10-16T02:38:20Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![MungbeanNoodle](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mungbeannoodle/32/11206_2.png) [@MungbeanNoodle](https://forum.babylonjs.com/u/MungbeanNoodle)\
**Post date:** [October 16, 2020, 2:38am UTC](https://forum.babylonjs.com/t/sandbox-material-binding-problem/14951/1 "2020-10-16T02:38:20Z")

</div>

In sandbox, I create two node materials and bind them to different models. When I export the scene as a .babylon file and import it again, the material of the two models both become the newest created material. The binding is broken. Then I test the other two types of Materials and there exists the same problem.  
[![](https://static.dingtalk.com/media/lALPD26eM-XmBprNAQjNAUs_331_264.png_720x720q90g.jpg?bizType=im) ](https://static.dingtalk.com/media/lALPD26eM-XmBprNAQjNAUs_331_264.png_720x720q90g.jpg?bizType=im)

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [October 16, 2020, 8:40am UTC](https://forum.babylonjs.com/t/sandbox-material-binding-problem/14951/2 "2020-10-16T08:40:05Z")

</div>

Could you provide a repro of the problem in the Playground?

---

<div class="post-metadata">

**Author:** ![MungbeanNoodle](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mungbeannoodle/32/11206_2.png) [@MungbeanNoodle](https://forum.babylonjs.com/u/MungbeanNoodle)\
**Post date:** [October 19, 2020, 8:24am UTC](https://forum.babylonjs.com/t/sandbox-material-binding-problem/14951/3 "2020-10-19T08:24:11Z")

</div>

I think it’s not possible to repro it in the playground but easy to find out what’s going wrong if do it again in sandbox as described

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [October 19, 2020, 3:37pm UTC](https://forum.babylonjs.com/t/sandbox-material-binding-problem/14951/4 "2020-10-19T15:37:31Z")

</div>

Pinging @Drigax to check our bjs exporter

---

<div class="post-metadata">

**Author:** ![MungbeanNoodle](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mungbeannoodle/32/11206_2.png) [@MungbeanNoodle](https://forum.babylonjs.com/u/MungbeanNoodle)\
**Post date:** [October 27, 2020, 8:35am UTC](https://forum.babylonjs.com/t/sandbox-material-binding-problem/14951/5 "2020-10-27T08:35:10Z")

</div>

> <https://github.com/BabylonJS/Babylon.js/blob/33cf7a6f9b035961fa8f290eba528c367c1cd962/src/Meshes/mesh.ts#L3091>

---

<div class="post-metadata">

**Author:** ![MungbeanNoodle](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mungbeannoodle/32/11206_2.png) [@MungbeanNoodle](https://forum.babylonjs.com/u/MungbeanNoodle)\
**Post date:** [October 27, 2020, 8:36am UTC](https://forum.babylonjs.com/t/sandbox-material-binding-problem/14951/6 "2020-10-27T08:36:42Z")

</div>

Maybe use this.material.uniqueId instead of this.material.id

---

<div class="post-metadata">

**Author:** ![MungbeanNoodle](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mungbeannoodle/32/11206_2.png) [@MungbeanNoodle](https://forum.babylonjs.com/u/MungbeanNoodle)\
**Post date:** [October 27, 2020, 8:52am UTC](https://forum.babylonjs.com/t/sandbox-material-binding-problem/14951/7 "2020-10-27T08:52:08Z")

</div>

@Deltakosh@Drigax

---

<div class="post-metadata">

**Author:** ![Drigax](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/drigax/32/16585_2.png) [@Drigax](https://forum.babylonjs.com/u/Drigax)\
**Post date:** [October 27, 2020, 3:30pm UTC](https://forum.babylonjs.com/t/sandbox-material-binding-problem/14951/8 "2020-10-27T15:30:46Z")

</div>

Thanks for taking a look!, I’m not sure how that may affect export offhand, but what are the material ids of your imported node materials?

I’ll try to take a look in the next few days, I’ve been mostly occupied working on Native at the moment.

---

<div class="post-metadata">

**Author:** ![Drigax](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/drigax/32/16585_2.png) [@Drigax](https://forum.babylonjs.com/u/Drigax)\
**Post date:** [October 27, 2020, 6:30pm UTC](https://forum.babylonjs.com/t/sandbox-material-binding-problem/14951/9 "2020-10-27T18:30:00Z")

</div>

Ok, I see what you mean now, If I export a scene with a number of in-scene created node materials, i can see the resulting .babylon scene has a number of node materials in it with `"id": "node material"`

and all the meshes are pointing to a material with `"id": "node material"` even though in scene, they have unique ids.

Personally i don’t think exporting unique ids is a good idea, because they are intended to be scene-unique, but not necessarily globally unique… if we round trip something, the unique id of it will change between scenes.

I don’t really think this is a fault of the exporter, but rather a fault of the node material creation stage. we should probably try to give the newly created material a unique id, instead of just “node material”

Let me see if i can make that change real quick…

---

<div class="post-metadata">

**Author:** ![Drigax](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/drigax/32/16585_2.png) [@Drigax](https://forum.babylonjs.com/u/Drigax)\
**Post date:** [October 27, 2020, 8:53pm UTC](https://forum.babylonjs.com/t/sandbox-material-binding-problem/14951/10 "2020-10-27T20:53:37Z")

</div>

opened [Node Materials created in sandbox share id · Issue #9290 · BabylonJS/Babylon.js · GitHub](https://github.com/BabylonJS/Babylon.js/issues/9290)

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [October 28, 2020, 2:44pm UTC](https://forum.babylonjs.com/t/sandbox-material-binding-problem/14951/11 "2020-10-28T14:44:54Z")

</div>

and merged…thanks @Drigax

---

<div class="post-metadata">

**Author:** ![MungbeanNoodle](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mungbeannoodle/32/11206_2.png) [@MungbeanNoodle](https://forum.babylonjs.com/u/MungbeanNoodle)\
**Post date:** [October 29, 2020, 1:50am UTC](https://forum.babylonjs.com/t/sandbox-material-binding-problem/14951/12 "2020-10-29T01:50:17Z")

</div>

Thanks @Evgeni_Popov @Deltakosh@Drigax
