Skip to content

Danishyousuf19/Schwarzschild-Black-Hole-Simulation-Gemini-3-pro

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

4 Commits
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ•ณ๏ธ Schwarzschild Black Hole Simulation (Web-Based)

A real-time, physically accurate visual simulation of a Schwarzschild black hole and its accretion disk.
This project uses WebGL (via Three.js) and custom GLSL fragment shaders to solve the geodesic equations that describe how light curves around a massive object โ€” all inside your browser.

Note: The physics engine, shader math, and rendering logic were generated using Google Gemini.


๐Ÿš€ Features

  • Raymarching in Curved Spacetime
    Simulates non-Euclidean geometry by integrating geodesics instead of using standard 3D rays.

  • Gravitational Lensing
    Produces Einstein Rings & realistic space-warping around the black hole.

  • Volumetric Accretion Disk
    Not a flat texture โ€” a fully volumetric sampled field with noise-based turbulence.

  • Relativistic Beaming (Doppler Shift)
    Approaching side appears bright/blue; receding side becomes dim/red.

  • Gravitational Redshift
    Light near the event horizon fades to deep red as it loses energy.

  • Photon Ring Visualization
    Shows the unstable orbit at ~1.5 Schwarzschild radii.

  • Adaptive Step-Size Integration
    Higher precision near the event horizon; faster simulation in empty space.


๐Ÿ› ๏ธ Technology Stack

  • HTML5 / JavaScript โ€“ Core structure
  • Three.js โ€“ WebGL setup & user interaction
  • GLSL (Fragment Shader) โ€“ 99% of the physics + rendering pipeline runs on GPU

๐Ÿ“ The Physics (How It Works)

Traditional 3D engines assume straight-line light travel.
This simulation instead performs raymarching with geodesic integration:

  1. Camera emits a ray for each pixel
  2. Ray marches forward in tiny steps
  3. At every step:
    • Gravity is computed from the Schwarzschild metric
    • Ray velocity is updated (curved path)
  4. If the ray intersects the accretion disk:
    • Gas density, rotation velocity & temperature determine pixel color

Simplified gravitational acceleration


๐ŸŽฎ Controls

  • Left Click + Drag โ†’ Orbit camera
  • Scroll Wheel โ†’ Zoom (get dangerously close!)

๐Ÿค– Credits

  • Concept & Prompt Engineering: DรNISH
  • Physics & Shader Code Generation: Google Gemini

Created as part of an exploration into AI-assisted GPU graphics and relativistic rendering.


About

A real-time WebGL simulation of a Schwarzschild black hole with accurate gravitational lensing and volumetric accretion disk rendering.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages