Search code examples
javagraphicslibgdx2dlight

LibGDX: light up the objects, that drop shadows


guys. I have a procedurally generated dungeon, that looks like this (tmp art):

enter image description here

With simple lighting, I can get this result:

enter image description here

It looks almost perfect (tho, the colors are a bit strange :X). But is there any way for the walls to get some light also? Like this:

enter image description here

this.light = new RayHandler(this.world);
this.light.setBlurNum(1);
this.light.setAmbientLight(0f);
this.point = new PointLight(this.light, 128, new Color(1, 1, 0.8f, 0.8f), 512, 300, 300);

Thanks a bunch 🙂 P.S. I know, that I can draw walls on top of the shadows, but how do I query the darkness, then?


Solution

  • It looks like you are using Box2dLights. If that is the case each light can have it's softness and distance set with the code below:

        light.setDistance(size); // how far the light goes
        light.setSoftnessLength(soft); // how deep it penetrates objects