advanced

#37 2D Platformer Lighting

Dynamic point lights for 2D scenes

Dynamic 2D lighting transforms flat game scenes into atmospheric environments. Each point light has position, color, radius, and intensity. Brightness at any pixel uses inverse-distance falloff with smoothstep for clean fade-out. Multiple lights combine through additive blending, creating bright intersections where they overlap. One light follows the mouse, simulating a player-carried torch.

Key Concepts

Try this shader live in the Shader Sandbox editor with real-time preview.
Open in Sandbox

Source Code


    
← Previous Retro CRT Effect Next → Parallax Scrolling

All Tutorials