When I call the material.freeze method and I change the color of the material, why does the color change take effect in the scene? Looks like the actual situation doesn’t match the description on the website.
…
mat.unfreeze();
–change Material Options–
mat.freeze();
…
If you change the material’s options as soon as you unfreeze it, and then freeze it afterwards, it won’t unfreeze.
with a small delay, but…
This seems to be more of a bug
You should normally be able to simply call material.markDirty() / material.markDirty(true) to update a frozen material, without having to call unfreeze.
However, we have an issue in the tracker to improve the management of frozen materials:
I found that my local project references the @babylonjs/core dependency package, and calling markDirty does not work after the material is frozen. And it’s normal on the playground.
This is my local pull 6.10.0 version code and playground code screenshots, they are not the same!
In addition, my local @babylonjs/core also has problems with morph under webGPUEngine. Modifying the influence from 0 to 1 will cause the model to scale, but the playground is normal.
Why is the code referenced by 6.10.0 @babylonjs/core and playground different?
Good news, the WebGPUEngine morph issue is now fixed after the update.
The markDirty of the material is still invalid, seemingly because subMesh.effect is null. Under what circumstances does effect become null?
I did call resetDrawCache, because the affected materials sometimes don’t recompile when the lights in the scene are destroyed. After fixing the version, this issue does not seem to exist either.
Thank you so mush. This sentence should be deleted,“scene.onAfterRenderObservable.add(() => mat.freeze());”.But it still toke effect when I clicked.Probably because chrome & macOS doesn’t support ubo.
I’ll have a try and hope I don’t run into those bugs, hhh.
I have a question I want to confirm with you again.In rendering optimization, material.freeze can play a great effect. It doesn’t just reduce the computation on the CPU, right?