Hello!
I have encountered a bug which manifests itself by some meshes disappearing from view when a particle system is enabled.
Through some debugging I have found an approximate explanation of the events leading up to, and causing the bug, plus a proof-of-concept fix.
Here's an explanation that I hope is reasonably accurate:
The underlying cause of the bug is that during SceneManager::_renderPhase02, the _updateRenderQueue function of the particle system's BillboardSet is called. The first time this happens, the BillboardSet creates and binds buffers for its geometry. As it happens, it is currently not guaranteed that the V1 global VAO is bound at this point in time. Instead, the VAO of a different renderable might still be bound. If that happens, the state of said VAO gets clobbered by the call to glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, x), and it will never draw properly again due to the incorrect GL_ELEMENT_ARRAY_BUFFER.
To "solve" this, I inserted a call to mDestRenderSystem->_startLegacyV1Rendering() before the loop calling _updateRenderQueue in SceneManager::_renderPhase02. I don't expect this to be the proper fix, but it illustrates the issue. With this in place, VAO 1 will be bound during the particle system's buffer creation, and other meshes won't get their VAO state messed up.
Another possibly required component to trigger the issue might be some unrelated Items using HlmsLowLevel (old Materials on Items), which seem to be the ones whose VAO's are bound at the moment of particle system creation.
I defer to better knowing people to devise a proper fix
[2.1] VAO corruption bug with mixed V1/V2 rendering Topic is solved
-
- Gremlin
- Posts: 184
- Joined: Sat Apr 16, 2016 9:25 pm
- x 19
- dark_sylinc
- OGRE Team Member
- Posts: 5296
- Joined: Sat Jul 21, 2007 4:55 pm
- Location: Buenos Aires, Argentina
- x 1278
- Contact:
Re: [2.1] VAO corruption bug with mixed V1/V2 rendering
Breathe in, breathe out.
**sigh**
Yes, your fix is most likely the best solution.
**sigh**
Yes, your fix is most likely the best solution.
-
- Gremlin
- Posts: 184
- Joined: Sat Apr 16, 2016 9:25 pm
- x 19
Re: [2.1] VAO corruption bug with mixed V1/V2 rendering
Keep calm
Thanks for pushing the fix!
Thanks for pushing the fix!