hawkwind
Junior Member  
Java games rock!
|
 |
«
Posted
2006-11-08 02:42:56 » |
|
In this case I am trying to remove a light from the scenegraph, surprisingly this ends up as an addLight down the stack trace causing me to use more lights than I should.
==>remove from bg org.xith3d.scenegraph.PointLight@188655e Exception in thread "Thread-10" java.lang.ArrayIndexOutOfBoundsException: 8 at org.xith3d.render.shader.LightingShader.addLight(LightingShader.java:90) at org.xith3d.render.prerender.AtomsCollector.collectGroupAtoms(AtomsCollector.java:258) at org.xith3d.render.prerender.AtomsCollector.collectNodeAtoms(AtomsCollector.java:402) at org.xith3d.render.prerender.AtomsCollector.collectAtoms(AtomsCollector.java:451) at org.xith3d.render.ScenegraphModificationsManager.onChildRemovedFromGroup(ScenegraphModificationsManager.java:259) at org.xith3d.scenegraph.GroupNode.removeChild(GroupNode.java:246) at hawk.manager.LightManager.enableSet(LightManager.java:344)
|
|
|
|
|
Marvin Fröhlich
|
 |
«
Reply #1 - Posted
2006-11-08 12:55:48 » |
|
In this case I am trying to remove a light from the scenegraph, surprisingly this ends up as an addLight down the stack trace causing me to use more lights than I should.
==>remove from bg org.xith3d.scenegraph.PointLight@188655e Exception in thread "Thread-10" java.lang.ArrayIndexOutOfBoundsException: 8 at org.xith3d.render.shader.LightingShader.addLight(LightingShader.java:90) at org.xith3d.render.prerender.AtomsCollector.collectGroupAtoms(AtomsCollector.java:258) at org.xith3d.render.prerender.AtomsCollector.collectNodeAtoms(AtomsCollector.java:402) at org.xith3d.render.prerender.AtomsCollector.collectAtoms(AtomsCollector.java:451) at org.xith3d.render.ScenegraphModificationsManager.onChildRemovedFromGroup(ScenegraphModificationsManager.java:259) at org.xith3d.scenegraph.GroupNode.removeChild(GroupNode.java:246) at hawk.manager.LightManager.enableSet(LightManager.java:344)
Well, every time you add or remove a Light, something called "shaderstate" needs to be rebuilt for all affected Groups and Shapes. This means to readd all remaining Lights to the newly created shaderstates. I'll check the ArrayIndexOutOfBoundsException. Marvin
|
|
|
|
|
Amos Wenger
|
 |
«
Reply #2 - Posted
2006-11-08 16:52:20 » |
|
Well, every time you add or remove a Light, something called "shaderstate" needs to be rebuilt for all affected Groups and Shapes. This means to readd all remaining Lights to the newly created shaderstates. I'll check the ArrayIndexOutOfBoundsException.
Is that optimizable ?
|
"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
|
|
|
Games published by our own members! Check 'em out!
|
|
hawkwind
Junior Member  
Java games rock!
|
 |
«
Reply #3 - Posted
2006-11-08 17:03:27 » |
|
The trouble is I have many lights but only 8 or less enabled at a time. The current processing is enabling more lights than Xith/Opengl support simultaneously. There is no reason why I cannot have 200 lights in a scenegraph if 8 or less are enabled
|
|
|
|
|
Amos Wenger
|
 |
«
Reply #4 - Posted
2006-11-08 17:31:35 » |
|
Yeah I don't know how it should be handled, when more than eight light are enabled at the same time... maybe throw a self-explanative exception ?
|
"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
|
|
|
hawkwind
Junior Member  
Java games rock!
|
 |
«
Reply #5 - Posted
2006-11-08 18:05:59 » |
|
I think it is more that the internals are enabling lights that I am not...if a light is not enabled then it shouldn't BE enabled internally
|
|
|
|
|
Marvin Fröhlich
|
 |
«
Reply #6 - Posted
2006-11-08 19:49:52 » |
|
Well, every time you add or remove a Light, something called "shaderstate" needs to be rebuilt for all affected Groups and Shapes. This means to readd all remaining Lights to the newly created shaderstates. I'll check the ArrayIndexOutOfBoundsException.
Is that optimizable ? Certainly. But not too easily. It certainly is a lower priorized task, isn't it? The trouble is I have many lights but only 8 or less enabled at a time. The current processing is enabling more lights than Xith/Opengl support simultaneously. There is no reason why I cannot have 200 lights in a scenegraph if 8 or less are enabled
I guess you're talking about added/removed Lights. But you should maybe consider enabling/disabling them. Then the shaderstates don't need to be rebuilt. Yeah I don't know how it should be handled, when more than eight light are enabled at the same time... maybe throw a self-explanative exception ?
Indeed. Marvin
|
|
|
|
|
Marvin Fröhlich
|
 |
«
Reply #7 - Posted
2006-11-09 02:58:09 » |
|
In this case I am trying to remove a light from the scenegraph, surprisingly this ends up as an addLight down the stack trace causing me to use more lights than I should.
==>remove from bg org.xith3d.scenegraph.PointLight@188655e Exception in thread "Thread-10" java.lang.ArrayIndexOutOfBoundsException: 8 at org.xith3d.render.shader.LightingShader.addLight(LightingShader.java:90) at org.xith3d.render.prerender.AtomsCollector.collectGroupAtoms(AtomsCollector.java:258) at org.xith3d.render.prerender.AtomsCollector.collectNodeAtoms(AtomsCollector.java:402) at org.xith3d.render.prerender.AtomsCollector.collectAtoms(AtomsCollector.java:451) at org.xith3d.render.ScenegraphModificationsManager.onChildRemovedFromGroup(ScenegraphModificationsManager.java:259) at org.xith3d.scenegraph.GroupNode.removeChild(GroupNode.java:246) at hawk.manager.LightManager.enableSet(LightManager.java:344)
Fixed  . Marvin
|
|
|
|
|
Amos Wenger
|
 |
«
Reply #8 - Posted
2006-11-09 18:45:14 » |
|
Well, every time you add or remove a Light, something called "shaderstate" needs to be rebuilt for all affected Groups and Shapes. This means to readd all remaining Lights to the newly created shaderstates. I'll check the ArrayIndexOutOfBoundsException.
Is that optimizable ? Certainly. But not too easily. It certainly is a lower priorized task, isn't it? The trouble is I have many lights but only 8 or less enabled at a time. The current processing is enabling more lights than Xith/Opengl support simultaneously. There is no reason why I cannot have 200 lights in a scenegraph if 8 or less are enabled
I guess you're talking about added/removed Lights. But you should maybe consider enabling/disabling them. Then the shaderstates don't need to be rebuilt. OK so that's really not a big performance problem, just adds all your lights at the beginning of the scene and enable/disable them... maybe a transparent pool of lights could be used ?
|
"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
|
|
|
hawkwind
Junior Member  
Java games rock!
|
 |
«
Reply #9 - Posted
2006-11-21 01:13:50 » |
|
Its back.....When using latest SVN pull as of last night
Exception in thread "Thread-10" java.lang.ArrayIndexOutOfBoundsException: 8 at org.xith3d.render.shader.LightingShader.addLight(LightingShader.java:96) at org.xith3d.render.prerender.AtomsCollector.collectGroupAtoms(AtomsCollector.java:248) at org.xith3d.render.prerender.AtomsCollector.collectNodeAtoms(AtomsCollector.java:398) at org.xith3d.render.prerender.AtomsCollector.collectAtoms(AtomsCollector.java:447) at org.xith3d.render.ScenegraphModificationsManager.onChildRemovedFromGroup(ScenegraphModificationsManager.java:244) at org.xith3d.scenegraph.GroupNode.removeChild(GroupNode.java:260) at hawk.manager.LightManager.enableSet(LightManager.java:344) at hawk.jcd.Xith3DFrame.runx(Xith3DFrame.java:746) at hawk.jcd.Xith3DFrame.loopIteration(Xith3DFrame.java:616) at org.xith3d.render.loop.RenderLoop.run(RenderLoop.java:882) at java.lang.Thread.run(Unknown Source)
Just to set my situation....I have N rooms, each with one or more lights, potentialy giving 30-50 lights, less than 8 of which are in the scenegraph at any time.. Based on user interaction I add or remove lights from the scenegraph. In the stack trace above I am removing a light from the scene, from within the RenderLoop. I cannot imagine why the light I am removing is being added...any thoughts appreciated
|
|
|
|
|
Games published by our own members! Check 'em out!
|
|
Marvin Fröhlich
|
 |
«
Reply #10 - Posted
2006-11-21 01:34:27 » |
|
Its back.....When using latest SVN pull as of last night
God dammed...  ...I cannot imagine why the light I am removing is being added...any thoughts appreciated
As I said before, when a Light or Fog is removed, the shader state needs to be rebuilt. This is done by readding the Lights and Fogs. This is why Lights are added, when a Light actually is removed. I've applied a fix, that should solve the problem. Please do revert, if it doesn't. Marvin
|
|
|
|
|
hawkwind
Junior Member  
Java games rock!
|
 |
«
Reply #11 - Posted
2006-11-21 01:38:49 » |
|
I looked briefly at the atom stuff and the test for lighting is checking for renderable not enabled. This is the stuff that always confuses me...is a not-enabled light renderable??? Seems like no to me but there are two separate states that describe whether a light is visible or not....YUCK!! I will try and set light as not-renederable when i set them not enabled.
|
|
|
|
|
Marvin Fröhlich
|
 |
«
Reply #12 - Posted
2006-11-21 01:51:12 » |
|
I looked briefly at the atom stuff and the test for lighting is checking for renderable not enabled. This is the stuff that always confuses me...is a not-enabled light renderable??? Seems like no to me but there are two separate states that describe whether a light is visible or not....YUCK!! I will try and set light as not-renederable when i set them not enabled.
This won't do the trick! I've added a comment to AtomsCollector and committed. I'll quote it here: * check here for isRenderable(), since ScenegraphModificationManager sets * a Light or Fog temporarily to non renderable before the atoms are recollected. * This is done, because the Atoms must be recollected before the Light or Fog * is actually removed from the scenegraph, to enable the collector to remove the * atom.
And a not-enabled Light is still renderable. I hope this answers your question. Marvin
|
|
|
|
|
hawkwind
Junior Member  
Java games rock!
|
 |
«
Reply #13 - Posted
2006-11-21 22:43:20 » |
|
Yee Heee found it.!!!!
..at least for my situation. The code is adding my lights multiple times to the array that throws the exception. Since I don't have dev rights could someone mod the code to determine if a Light is already in the array before attempting to add it and up the Light count.
at org.xith3d.render.shader.LightingShader.addLight(LightingShader.java:96) at org.xith3d.render.prerender.AtomsCollector.collectGroupAtoms(AtomsCollector.java:248) at org.xith3d.render.prerender.AtomsCollector.collectNodeAtoms(AtomsCollector.java:398) at org.xith3d.render.prerender.AtomsCollector.collectAtoms(AtomsCollector.java:447)
|
|
|
|
|
Marvin Fröhlich
|
 |
«
Reply #14 - Posted
2006-11-21 22:46:29 » |
|
Yee Heee found it.!!!!
..at least for my situation. The code is adding my lights multiple times to the array that throws the exception. Since I don't have dev rights could someone mod the code to determine if a Light is already in the array before attempting to add it and up the Light count.
at org.xith3d.render.shader.LightingShader.addLight(LightingShader.java:96) at org.xith3d.render.prerender.AtomsCollector.collectGroupAtoms(AtomsCollector.java:248) at org.xith3d.render.prerender.AtomsCollector.collectNodeAtoms(AtomsCollector.java:398) at org.xith3d.render.prerender.AtomsCollector.collectAtoms(AtomsCollector.java:447)
Well, that was exactly, what I fixed yesterday  Don't know, if you checked out after I posted it here. Marvin
|
|
|
|
|
hawkwind
Junior Member  
Java games rock!
|
 |
«
Reply #15 - Posted
2006-11-21 23:53:44 » |
|
cool 
|
|
|
|
|
|