# LibGDX - Box2D: Realistic Light and Layers

I'm having some problems with my current game. Short description: It's a 2D game where you have to avoid the lights or you lose HP.

My problem is the following one:

Here is the rendering process:

1. The background is drawn
2. The Moon image is drawn
3. The point light is applied
4. The collision layer and the images attached to it are drawn
5. Player is drawn
6. The foreground image (on the top left and bottom middle)

My problem is that the rendering does not look realistic. I need some help on how I could make the light coming from "behind" the collisions and applying it everywhere.

• Do you mean that the light isn't diffused around corners? Mar 14 '14 at 10:52
• I mean that i don't want the light to stop at the top of the branch but go "behind" the branch. Mar 14 '14 at 14:17

ideally, you configure group/mask for your lights and objects. Using this, you can tell your point light to ignore those branches. See a great write-up here.

alternatively, as a brute force approach, you could render lights before you draw your branch (though you should REALLY use the mask approach above):

// draw all objects that should create shadows
batch.begin();
...
batch.end();

rayHandler.setCombinedMatrix(camera.combined);
rayHandler.updateAndRender();