I noticed that there is a way to modify the material in the document, but the material cannot be modified actually
mawa
August 10, 2023, 9:18am
2
What do you mean? Is it within an animation or something?
I’m not sure what the intermediate mode does just exactly besides freezing meshes, but I experienced that in some cases, it was not the freeze but the dirty mechanism preventing the update.
You could try add this line to see if it makes a difference:
scene.blockMaterialDirtyMechanism = false;
Instead of unfreezing / freezing, try to call material.markDirty(true)
.
Better handling frozen materials is something on our list:
opened 06:05PM - 26 Apr 23 UTC
enhancement
rendering engine
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)` - comment `mat.freeze()` to see it working
* https://forum.babylonjs.com/t/what-cant-be-safely-changed-when-freezing-materials/41103
=> same than above, the `texture.vScale=-1` is not applied correctly
* https://playground.babylonjs.com/#7MXSEV#5
=> a single sphere turns red (the first one) because after the color is updated for it, `effect._forceRebindOnNextCall` is set to `false`, so the other spheres won't execute the uniform buffer update code (because all the spheres use the same effect)
* https://forum.babylonjs.com/t/cross-browser-performance-priority-material-bug/42792/3
=> it is using the `Intermediate` performance mode
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).
Also, the doc should be updated:
* https://doc.babylonjs.com/features/featuresDeepDive/scene/optimize_your_scene#performance-priority-modes
Instead of unfreezing when something needs to be changed on the material, one should probably call `markDirty(true)` instead.
1 Like
markDirty
Only one material takes effect
Yes, it’s a known problem with the current system and is reported in the 4th bullet point in Materials: improve management of frozen materials · Issue #13776 · BabylonJS/Babylon.js · GitHub .
A workaround is to call markDirty
in the onUnbind
observable:
2 Likes