ForwardRendering: SceneNode.removeRenderable can cause lights to not render for 1 frame
jakobmulvad opened this issue · 9 comments
I experience that sometimes when I remove a renderable from a scenenode the screen would flicker for one frame. By slowing down the visual framerate I can see that the lights are turned off in this frame (except ambient light) and then turned back on in the next frame.
I'm using forwardrendering with shadowmaps.
Sorry but I can not reproduce this issue with our forward_rendering sample, I modified it to remove a renderable whenever I pressed a key and nothing flickered. I tried all the light types, with dynamic and static scene nodes, removing renderables in different orders, visible or invisible, with one or more lights, and I tried several different update intervals, but I never got any lights turned off.
Perhaps this is already fixed in the version I am testing on (which we are planning to release soon) but otherwise we are going to need a reproducible in order to help you.
Btw, I assume you are using "scenenode.removeRenderable(renderable)".
Thank you for looking into this.
I can build a version of my game that provokes this problem often, would that be useful? or would you require an isolated test scenario?
Yes I'm using scenenode.removeRenderable(renderable)
The smaller and simpler the better for us.
I have successfully created a small test case that reliably reproduces this issue.
go here: http://nerf.dk/renderablesbug/renderablesbug.debug.html
The lights should flicker for you in this test, but the only thing that's going on is I'm adding and removing a renderable every frame. I have set the framerate to 10 fps so the effect is clearer.
Edit: I'm running windows 7/Radeon HD 6800 series/Chrome 32.0.1700.107
Wow! I found the bug, It happens when you remove the last renderable of the last dynamic node (or the last static node) of a scene with global directional lights.
I never noticed it because by the time I removed the last dynamic node or the last static node there was nothing else on the scene to receive light...
The bug was a bit indirect, the involved node received wrong extents that then propagated up to the scene extents that then affected the global light extents.
The fix is trivial, you can either wait for us to release the new version or modify the method "updateLocalExtents" on scenenode.ts, instead of
if (renderables || lights)
You need to do something like:
if ((renderables && renderables.length) || (lights && lights.length))
Our fix will be a bit more complicated because I am going to reorganize the method a bit.
Thanks David. Glad my work on creating the test case was not in vane. I'll try to apply your fix while I wait for the next release.
I have also noticed that I sometimes get WebGL warnings after removing renderables:
[.WebGLRenderingContext]GL ERROR :GL_INVALID_OPERATION : glDrawElements: attempt to access out of range vertices in attribute 0
I can't pinpoint exactly when it happens but it only seem to happen after I remove a renderable and it only happens for one frame (it doesn't spam the console every frame). Can this be related in any way?
Did you modify the geometry referenced by the renderable after removing it?
Was the renderable affected by a local light with shadows?
- I might have.. not sure. Will check up on that.
- No local light source
Could you try the latest version of the code from this repository and check if your issues are fixed?