Objects seem to not be rendered on the frame they are created on if it has a fresh material, even if that material is identical to another material (not cached?), and even if async shader compilation is off.
I’ve created three test cases showing unexpected/undesirable behavior. For every demo, pressing the space key will recreate the object and demo the issue. The code is nearly identical for all 3 examples, only lines 3 and 23 are changed.
- Async shader compilation: disabled
New object’s material: cloned
Result: flash due to object not being rendered on the first frame (unexpected behavior)
Babylon.js Playground - Async shader compilation: disabled
New object’s material: same material that already existed
Result: no flash (this is the expected behavior)
https://playground.babylonjs.com/#GQQGZQ#1 - Async shader compilation: enabled
New object’s material: same material that already existed
Result: flash due to object not being rendered on the first frame (unexpected behavior)
https://playground.babylonjs.com/#GQQGZQ#2
I would expect that in all three cases, there should be no flash due to the object not being rendered on the frame it is created. I believe the current flash behavior used to not be present, as I encountered this by upgrading a very old project from Babylon.js v6.16.0 to v9.18.2, and there was a visual issue that I noticed. I think the reproduction I have here is a minimal reproduction of the issue I was seeing, but I’m not 100% sure.