Lighting in 2D shaders works by calculating how far each pixel is from a light source and fading brightness with distance. A point light uses the inverse-square law — intensity / (distance * distance) — to create realistic falloff, bright near the source and dimming quickly. A softer glow uses intensity / (distance + epsilon) instead. The iMouse uniform lets the light follow your cursor, making the scene interactive. Tone mapping with col / (col + 1) prevents colors from blowing out to white.
Key Concepts
inverse-square falloff
glow formula
iMouse uniform
tone mapping
Try this shader live in the Shader Sandbox editor with real-time preview.