How to unfreeze and freeze in 6.0

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.

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)

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

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

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
PBR material: https://playground.babylonjs.com/#EPI4MZ#14

We will see if we can make this process easier…

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.

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.

I have created an issue for it:

4 Likes