Adding lightsources and objects casting shadows can really add to the visual appeal of a game. Tutorials and examples of this effect are fairly common (example: https://github.com/mattdesl/lwjgl-basics/wiki/2D-Pixel-Perfect-Shadows) and for Defold users @d954mas and Sayuris1 have shared their solutions here and on Discord:
- Problem with shader
- GitHub - Sayuris1/2d_light_defold: An example project to create lights and shadows with defold and shaders.
We’ve taken the project from Sayuris1, made a few improvements and packaged into a reusable sample project which can be added to any Defold project in just a few steps. Here’s the sample project:
And a demo: Lights 1.0 (move with arrow keys)