Load serialized scene duplicates texture

OS: Windows 10 x64
Browser: ungoogled-chromium 108.0.5359.95
Babylon.js: 5.37.0
Playground: Babylon.js Playground

Expected:
Texture not duplicated after serializing and loading.

Actual:
Texture duplicated.

ping @Evgeni_Popov

That’s expected.

The scene loader won’t reuse any Texture objects that may already exist because of side effects. Imagine that you want to change a property of the texture for your first object but you don’t want it to change for the 2nd object (the one you get after serialization/parsing). If you have only one Texture object, you can’t do this. However, the system reuses internal textures, so there’s no duplicate data / no duplicated GPU textures, you just have two separate Texture objects that you can update independently.

2 Likes