[SOLVED] Multimaterial is not applied correctly after freezing active meshes


It seems that there is some issue with how meshes with applied multimaterials react on freezing active meshes on the scene. Check out the playground - I used the example of multimaterial from the docs, and I do scene.freezeActiveMeshes(); after 3 sec. timeout.

From what I’ve seen so far, in the render method of Mesh class the following code sets _effectiveMaterial specific to the sub mesh:

// Material
if (!instanceDataStorage.isFrozen || !this._effectiveMaterial) {
    var material = subMesh.getMaterial();
    // ...
    this._effectiveMaterial = material;
    // ...

Presumably this needs to be done for every sub mesh of a mesh, but the problem is that _effectiveMaterial is a shared property, therefore as soon as active meshes get frozen, the instanceDataStorage.isFrozen becomes true, and _effectiveMaterial “stucks” with one material, so that other sub meshes of a mesh never render with their materials.

Not sure if I make sense though :slight_smile:

Tested BabylonJS version: 4.0.0-rc.3

Good catch!
Will be fixed by final 4.0 release :slight_smile:

1 Like

Thanks a lot!