This repo shows a demo for the idea using shadowmap in 2d unity game.
THIS IS ONLY A DEMO. It only contains very simple lighting behaviour, and it's not for making marvelous 2d graphics. It is only for providing the idea.
The method is of three steps.
- Create shadow line mesh for each shadow caster. This doesn't need to be done every frame.
- Render shadow mesh to each light's shadowmap. For point light, its shadowmap is 4 rows in the shadowmap texture(each row stands for a 90 degrees range).
- Use shadow map to draw light. In the demo, a simple additive light is used. It samples the shadow map and does shadowing.