[LibGDX] Top-down 2d game with pseudo 3d lighting.

Hello everyone!

I have been creating a top-down 2d game using LibGDX. I am trying to find a way to creating a lighting effect for this game. What I want to achieve is having lights that cast shadows. The size of the shadows depend on the height, width, and opacity or density of the object in the light path.

Here is an example.

In the image above the spheres are shorter and the shadow doesn’t reach as far, where as the columns are taller and the shadow is cast further.

I would like to implement this technique into my game using a main light source as the sun implemented on a day/night cycle. Here is an example in another game.


One thing I would like to avoid is the box2dlights with the hard rogue like lighting where each shadow is ridiculously unrealistic.

Thank you for your help! I did do some googling on the subject. Haven’t found anything that I thought would work.

Have you read this article by Careless Labs already?

He uses Box2DLights for soft and round shadows/lighting. Maybe you can use or adapt the box2dlights source to fit your profile, it very much looks like box2d supports smooth shadows.

What you want to achieve is basically full 3d sun shadow casting, this isn’t simple anymore, you can either fake it like box2d does or go all out with 3d-shadows and lots of OpenGL magic.