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

**URL:** <https://forum.babylonjs.com/t/solved-multimaterial-is-not-applied-correctly-after-freezing-active-meshes/2884>\
**Category:** Bugs\
**Created:** [April 30, 2019, 1:48pm UTC](https://forum.babylonjs.com/t/solved-multimaterial-is-not-applied-correctly-after-freezing-active-meshes/2884 "2019-04-30T13:48:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![alvov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/alvov/32/2061_2.png) [@alvov](https://forum.babylonjs.com/u/alvov)\
**Post date:** [April 30, 2019, 1:48pm UTC](https://forum.babylonjs.com/t/solved-multimaterial-is-not-applied-correctly-after-freezing-active-meshes/2884/1 "2019-04-30T13:48:07Z")

</div>

Hi!

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](https://www.babylonjs-playground.com/#2Q4S2S#42) - 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:

```auto
// 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 🙂

Tested BabylonJS version: 4.0.0-rc.3

---

<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:** [April 30, 2019, 2:54pm UTC](https://forum.babylonjs.com/t/solved-multimaterial-is-not-applied-correctly-after-freezing-active-meshes/2884/2 "2019-04-30T14:54:09Z")

</div>

> [@alvov](#):
>
> !instanceDataStorage.isFrozen || !this.\_effectiveMaterial

Good catch!  
Will be fixed by final 4.0 release 🙂

---

<div class="post-metadata">

**Author:** ![alvov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/alvov/32/2061_2.png) [@alvov](https://forum.babylonjs.com/u/alvov)\
**Post date:** [May 1, 2019, 7:59am UTC](https://forum.babylonjs.com/t/solved-multimaterial-is-not-applied-correctly-after-freezing-active-meshes/2884/3 "2019-05-01T07:59:06Z")

</div>

Thanks a lot!
