StellarLens is an interactive, real-time web application that visualizes the mesmerizing phenomenon of gravitational lensing around a black hole. Leveraging advanced 3D graphics, custom shaders, and modern web technologies.
Sample: Light rays bending around a black hole, with lensing graph overlay.
The Schwarzschild metric describes the spacetime geometry around a non-rotating, spherically symmetric mass such as a black hole. In Schwarzschild coordinates, the line element is:
where
For a light ray passing at impact parameter
This is the classic Einstein formula for gravitational lensing. For strong lensing (close to the event horizon), higher-order terms or numerical integration of the geodesic equations are required.
| Component | Description |
|---|---|
| Ray Tracing | Traces light rays backward from the camera through each pixel, computing deflection based on the Schwarzschild metric |
| GLSL Shader | Computes apparent position of background sources using lensing deflection, utilizing black hole mass and event horizon parameters |
| Numerical Integration | For accurate near-horizon visualization, integrates the null geodesic equations: |
The project combines the Schwarzschild metric, Einstein's deflection formula, and real-time GPU-based ray tracing to visualize gravitational lensing. The approach balances analytic solutions for efficiency and numerical integration for accuracy near the event horizon, all implemented in performant GLSL shaders for interactive exploration.
| Feature | Description |
|---|---|
| Real-Time 3D Visualization | Uses Three.js for high-performance, GPU-accelerated rendering |
| Physically-Inspired Lensing | Custom GLSL fragment shaders simulate light deflection based on Einstein radius |
| Interactive GUI Controls | lil-gui for real-time parameter adjustment |
| Ray Path Visualization | Visual representation of light ray bending around black holes |
| Post-Processing Effects | Cinematic bloom and glow using UnrealBloomPass and EffectComposer |
| Dynamic Info Panel | Real-time display of simulation parameters and debugging info |
| Lensing Graph Overlay | Interactive plots of deflection angles vs. impact parameters |
| Responsive Architecture | Clean ES modules and responsive UI for all devices |
- Three.js: 3D rendering, camera controls, scene management
- GLSL Shaders: Custom shaders for gravitational lensing simulation
- JavaScript ES Modules: Modern, modular codebase architecture
- HTML5 & CSS3: Responsive layouts and UI components
- Gravitational lensing
- Einstein radius calculation
- Event horizon physics
- Ray tracing in curved spacetime
- Light deflection in strong gravity fields
# Clone the repository
git clone https://github.com/Rhishavhere/StellarLens.git
# Navigate to project directory
cd StellarLens
# Install dependencies
npm install
# Start development server
npx serveOnce running, use the GUI controls to explore different lensing scenarios and visualize ray paths around the black hole.
- Adjust lensing strength, event horizon, and bloom via the GUI.
- Observe real-time changes in the visualization and info panel.
- View the lensing graph overlay for scientific analysis.
