libgdx / box2dlights

Fork of box2dlights by Kalle Hamalainen
Apache License 2.0
256 stars 81 forks source link

using multiple light layers #52

Open alwex opened 9 years ago

alwex commented 9 years ago

Hi, I think it could be a greate thing to be able to use multiple rayHandler (one per layer). The main loop could be like this:

// render layer 0 (background)
map.render(0);
rayHandler1.updateAndRender();
// render layer 1 (front)
map.render(1);
rayHandler2.updateAndRender();

To achieve this, I think that the light/shadow shader may be disabled when the alpha chanel of a pixel is equal to 0, this way, the shadow of the front layer wont be casted to the back layer anymore.

for an example, see towerfall ascension game, they make use of 2 light layers (the background is not affected by the light on the foreground).

http://www.gamesaktuell.de/screenshots/original/2013/11/towerfall_ascension_2-pc-games.JPG

lampione commented 8 years ago

This would be awesome, there are some major issues handling lights plus viewports. My game has multiple viewports and I can't sort this out.

rinold commented 8 years ago

Currently this might be achieved using rendering to FBO, which should work fine. Custom viewports are also supported (in wiki there is some info about viewports).