Sandbox material binding problem

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.

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

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

Pinging @Drigax to check our bjs exporter

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

@Deltakosh @Drigax

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.

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…

1 Like

opened Node Materials created in sandbox share id · Issue #9290 · BabylonJS/Babylon.js · GitHub

and merged…thanks @Drigax

Thanks @Evgeni_Popov @Deltakosh @Drigax