Lights related stuff

Ok I am playing with lights and I am missing methods for detaching all lights from the node or at least iterating over them and detaching one by one. It would also be good if each light would have some method to disable or enable it (currently there is only method to check if the light is enabled?).

use rootNode.removeLight(ligth);

if you want to iterate you can have a list of lights using rootNode.getWorldLightList();

How do lights impact performance any way? Lets say I’d like to put down lights programmatically which can easily amount to 100 lights.

Would an increased light count hit performance exponentially, or liniarly? Are there tricks to using many lights?

Ok thanks for your reply nehon, it helped.

Anyway, I still think there should be some method for enabling or disabling a light.

Another question from my side, what is the difference if I addLight to the rootNode or to any other sub node?

And what does radius really mean? In my simple test application, I put in a point light with really small radius and it still lights up the place a little. Only if I set radius to some big number, I see some change…

It depends

if you use classic rendering, there is one pass by light in the scene, which means 100 pass per frames with 100 lights…which will probably run at 0 fps.



Or you use deferred rendering and there is no change between 1 or 100 lights (in fact there is a slight change but not really as noticeable than the previous approach)

look at the TestMultiRenderTarget for an example.

Deferred lighting isn’t functional yet. I don’t recommend using 100 lights unless you have each applied to specific objects only

How can you apply light to a specific object only? :slight_smile:

Attach the light to it

Yeah, just use Nodes. The light will only work on subitems of the Node its attached to.

But lights also have a radius . What if they’re all small lights (and everything is on the root node), would it still be a strain?



Is there a good trick to, for instance, simulate lamps/torches on a wall?

Bump. :slight_smile:

So the best way to optimize lighting in a scene is to attach light to nodes that should be lighted? There is no optimizations including light radius?