An Android implementation of a lightweight "fake flashlight" / spotlight effect using OpenGL ES shaders. This project brings the beautiful lighting simulation from radiofun/LightingSim to Android.
LightingSimAndroid.mov
This Android port implements the same stunning visual effects as the original SwiftUI version:
- Expanding cone beam from a fixed light source
- Chromatic dispersion (RGB channel separation) for realistic color fringing
- Soft halo/glow effect around the main beam
- ACES tone-mapping for bright, vivid highlights without overexposure
- Interactive controls to adjust lighting parameters in real-time
Control the lighting effect with these adjustable parameters:
intensity— Overall brightness of the beamdisperse— Cone spread and chromatic separation strengthradius— Starting beam width at the light source
This Android implementation uses:
- OpenGL ES for GPU-accelerated rendering
- GLSL fragment shaders for the lighting calculations
- Custom View for real-time interaction and rendering
- Material Design components for the control interface
-
sdSegmentSim(p, a, b)— Distance field calculation returning:distancefrom pointpto the beam segment axist= clamped projection along the segment in[0, 1]
-
Beam profile uses:
beam = 1 - smoothstep(0, width, dist)- Softened with
pow(beam, softness)for smooth falloff
-
Chromatic dispersion uses a perpendicular vector:
perp = (-dir.y, dir.x)- Offset positions drive R and B channel separation
Simply run the app and use the sliders to adjust:
- Light intensity
- Beam dispersion/spread
- Beam radius
The lighting effect updates in real-time as you adjust the parameters.
Like the original, this is not true volumetric lighting—there's no geometry occlusion, scattering volumes, or dynamic shadows. Instead, it's a fast, UI-friendly illusion built from distance fields and carefully tuned falloffs that creates a convincing flashlight beam effect perfect for mobile applications.
This Android port is inspired by and based on the original iOS/SwiftUI implementation:
Original Project: radiofun/LightingSim
Original Author: @radiofun
Huge shoutout to the original author for creating such an elegant and beautiful shader effect! This Android port aims to bring that same visual quality to the Android platform.
Please refer to the original project for licensing information.