Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ForwardRendering: SceneNode.removeRenderable can cause lights to not render for 1 frame #29

Open
jakobmulvad opened this issue Feb 6, 2014 · 9 comments

Comments

@jakobmulvad
Copy link

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.

@davidgaleano
Copy link
Contributor

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)".

@jakobmulvad
Copy link
Author

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)

@davidgaleano
Copy link
Contributor

The smaller and simpler the better for us.

@jakobmulvad
Copy link
Author

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

@davidgaleano
Copy link
Contributor

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.

@jakobmulvad
Copy link
Author

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?

@davidgaleano
Copy link
Contributor

Did you modify the geometry referenced by the renderable after removing it?
Was the renderable affected by a local light with shadows?

@jakobmulvad
Copy link
Author

  1. I might have.. not sure. Will check up on that.
  2. No local light source

bmaltby pushed a commit that referenced this issue Mar 7, 2014
@davidgaleano
Copy link
Contributor

Could you try the latest version of the code from this repository and check if your issues are fixed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants