# How to unfreeze and freeze in 6.0

**URL:** <https://forum.babylonjs.com/t/how-to-unfreeze-and-freeze-in-6-0/40242>\
**Category:** Questions\
**Tags:** material\
**Created:** [April 26, 2023, 10:24am UTC](https://forum.babylonjs.com/t/how-to-unfreeze-and-freeze-in-6-0/40242 "2023-04-26T10:24:50Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![DKurtel](https://avatars.discourse-cdn.com/v4/letter/d/839c29/32.png) [@DKurtel](https://forum.babylonjs.com/u/DKurtel)\
**Post date:** [April 26, 2023, 10:24am UTC](https://forum.babylonjs.com/t/how-to-unfreeze-and-freeze-in-6-0/40242/1 "2023-04-26T10:24:50Z")

</div>

Hi,

I have read the newly released documentation however, I couldn’t make the unfreezing the materials work with any of the performance modes.

I’m trying to change the alpha of the material when performance mode is set however, I couldn’t change any attribute of the material. Also, when inspected from console the isfrozen function always returns true.

Here is a sample I was using to test.

> **[Babylon.js Playground](https://www.babylonjs-playground.com/#EPI4MZ%236)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [April 26, 2023, 1:12pm UTC](https://forum.babylonjs.com/t/how-to-unfreeze-and-freeze-in-6-0/40242/2 "2023-04-26T13:12:33Z")

</div>

Hello and welcome to the Babylon community!

For PBR Materials, if you force the material to be marked as dirty, it works without needing to unfreeze it: [Freezing materials | Babylon.js Playground (babylonjs-playground.com)](https://www.babylonjs-playground.com/#EPI4MZ#10)

However, that doesn’t seem to work with the Standard Material: [Freezing materials | Babylon.js Playground (babylonjs-playground.com)](https://www.babylonjs-playground.com/#EPI4MZ#9) @Evgeni_Popov is that intentional?

---

<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:** [April 26, 2023, 2:03pm UTC](https://forum.babylonjs.com/t/how-to-unfreeze-and-freeze-in-6-0/40242/3 "2023-04-26T14:03:38Z")

</div>



---

<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:** [April 26, 2023, 2:42pm UTC](https://forum.babylonjs.com/t/how-to-unfreeze-and-freeze-in-6-0/40242/4 "2023-04-26T14:42:17Z")

</div>

In fact, it doesn’t work with PBR either.

It works in your PG example only because the ground has a standard material: the sphere and the ground do not use the same effect underneath, that’s why it works. This PG does not work with PBR materials: [https://www.babylonjs-playground.com/#EPI4MZ#12](https://www.babylonjs-playground.com/#EPI4MZ#12)

The way to make it work is to reset to `Backward` mode, unfreeze the material and re-set `Intermediate` mode in the next frame, to give the system time to update the material properly:

Std material: [https://playground.babylonjs.com/#EPI4MZ#13](https://playground.babylonjs.com/#EPI4MZ#13)  
PBR material: [https://playground.babylonjs.com/#EPI4MZ#14](https://playground.babylonjs.com/#EPI4MZ#14)

We will see if we can make this process easier…

---

<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:** [April 26, 2023, 2:42pm UTC](https://forum.babylonjs.com/t/how-to-unfreeze-and-freeze-in-6-0/40242/5 "2023-04-26T14:42:19Z")

</div>



---

<div class="post-metadata">

**Author:** ![Kesshi](https://avatars.discourse-cdn.com/v4/letter/k/b782af/32.png) [@Kesshi](https://forum.babylonjs.com/u/Kesshi)\
**Post date:** [April 26, 2023, 5:30pm UTC](https://forum.babylonjs.com/t/how-to-unfreeze-and-freeze-in-6-0/40242/6 "2023-04-26T17:30:04Z")

</div>

The fact that you have to wait until the material was rendered was an issue for me several times already. How to be really sure that a material was really updated/rendered? For example if the corresponding mesh is currenty not inside the frustum. Some kind of `autoFreezeAfterUpdated` flag would be nice.

---

<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:** [April 26, 2023, 5:36pm UTC](https://forum.babylonjs.com/t/how-to-unfreeze-and-freeze-in-6-0/40242/7 "2023-04-26T17:36:17Z")

</div>

Yes, that’s what `material.markDirty(true)` is for normally, but it does not work in all cases currently. We need to improve on this one so that it will also work in your case.

---

<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:** [April 26, 2023, 6:06pm UTC](https://forum.babylonjs.com/t/how-to-unfreeze-and-freeze-in-6-0/40242/8 "2023-04-26T18:06:14Z")

</div>

I have created an issue for it:

> <https://github.com/BabylonJS/Babylon.js/issues/13776>
>
> See https://forum.babylonjs.com/t/how-to-unfreeze-and-freeze-in-6-0/40242
> 
> Als…o:
> \* https://playground.babylonjs.com/#ITQR47#7
> =\> this one does work because we call \`ground.resetDrawCache();\`, but calling \`ground.material.markDirty(true);\` instead should make it work (which is not the case)
> \* https://playground.babylonjs.com/#7PPJ1M#9
> =\> this one doesn't work even with \`resetDrawCache\` + \`markDirty(true)\`
> 
> The problem is that \`\_wasPreviouslyReady\`, \`\_wasPreviouslyUsingInstances\` and \`\_forceRebindOnNextCall\` which are currently stored on the effect should be stored on the \`DrawWrapper\` instead (that's because an effect can be shared by multiple submeshes).
