hearsilent/LightingSimAndroid

An Android implementation of a lightweight "fake flashlight" / spotlight effect using OpenGL ES shaders.

★ 0Forks 0KotlinGitHub ↗Compare
android-libraryglslspotlight

README

LightingSim - Android Port

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

Features

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

Parameters

Control the lighting effect with these adjustable parameters:

  • intensity — Overall brightness of the beam
  • disperse — Cone spread and chromatic separation strength
  • radius — Starting beam width at the light source

Implementation

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

Key Shader Features

  • sdSegmentSim(p, a, b) — Distance field calculation returning:

    • distance from point p to the beam segment axis
    • t = 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

Usage

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.

Why "Faux" Lighting?

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.

Credits

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.

License

Please refer to the original project for licensing information.

Contributors

hearsilent

Issues