There seems to be an issue on disposing translucent meshes when Order Independant Transluency is on : it looks like the OIT framebuffer is not cleared when calIing dispose. I already posted it in this topic but I recreate here to be more visible.
@CraigFeldspar FYI, here is a playground that load two meshes with OIT and then dispose it after a delay
Can’t see much with this PG. May be you could add a button or kb to add or remove.
Anyways, I’m still questionning myself if you should use OIT at all for this kind of (dynamic) behavior in scene. I believe the function is based on re-ordering layers and alpha blending; feels like complicated to me and it doesn’t really wonder me that it might create bugs depending on context. You would likely need to rely on things like onBefore and/or AfterRender on mesh disposal or reorg of your scene meshes. Do you really need it? Isn’t there any other way you might not have investigated/considered?
I updated the PG here to add the timeout in the callback to make sure that we dispose the meshes after everything is loaded, so you can see that we are unable to dispose a mesh that is translucent when OIT is activated.
Maybe I explained badly the issue here : I have OIT enabled, and then at some time I want to dispose a mesh but the OIT framebuffer is not cleared properly
No, you explained it fine. This is precisely the point I’m questionning; I also believe the OIT framebuffer would probably not clear (and/or reorder all properly) on a mesh disposal. On the other hand, I was just challenging the feature itself. I’m not sure this is just a simple bug to be fixed easily anytime soon.
I guess best would be to call-in some people who might be able to answer. @sebavan @Evgeni_Popov . See what this people have to say about it.
This is indeed a bug with the OIT post process, it is still applied, even though no more transparent meshes are present on the scene. It happens only in that case, if you add another transparent like in this PG, it works fine : https://playground.babylonjs.com/#WGZLGJ#4916
Thanks ! Should I use the workaround (ie. always let a translucent object in the scene) or is the OIT post process easy to fix ?
You can use the workaround while I will work on a fix for OIT