Closed fgnm closed 8 months ago
Works flawlessly to implement in my LibGDX liftoff project. I am so thankful.
@n1cken you can find a more up to date fork here where I ported normal maps too :) https://github.com/rednblackgames/hyperlap2d-runtime-libgdx/tree/master/src/main/java/games/rednblack/editor/renderer/box2dLight
This is a huge update of box2dLights as I've ported all the works made by @rinold and @kdenzel about
pseudo3d
lights into current box2dLights implementation. I've also fixed some minor issue withRayHandler
configuration by introducingRayHandlerOptions
object to initializediffuse
,pseudo3d
andgammaCorrection
. This means breaking change as I've removed static setters and static public variables.The result is however much more clean and easy to understand, this is an example how to use new configuration:
Removing static functions makes also possible to switch
diffuse
,gammaCorrection
andpseudo3d
at runtime without re-create FBOs (as point out in #123). To do that I've add the following functions toRayHandler
:What's working in pseudo3d
Chain Lights are not supported yet.
Test pseudo3d
This works quite different from base lights, as each shadow is mesh and rendered after the main light mesh. Lights and objects now has the
height
parameter needed to get the pseudo3d effect. Light's height can be easily set withlight.setHeight(lightHeight)
, while ANY fixture that has to be recognized with a pseudo3d light must have a custom user data attached:body.createFixture(fixtureDef).setUserData(new LightData(objectHeight));
.A working example could be found in
Box2dLightTest2
class.Tested on desktop and Android without notable issue.
I know that this is a big PR and actually no one is working actively on box2dLights, but merging this might encourage others to contribute and extend support to pseudo3d features. A side from
RayHandlerOptions
, pseudo3d functionality does not create disturb to normal box2dLights as it continue working as usual.