MCPcopy Index your code
hub / github.com/dgreenheck/webgpu-black-hole

github.com/dgreenheck/webgpu-black-hole @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
51 symbols 99 edges 6 files 24 documented · 47%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

WebGPU Black Hole

A real-time black hole visualization using WebGPU, Three.js, and TSL (Three.js Shading Language). Features physically-inspired gravitational lensing, an accretion disk with blackbody radiation coloring, and procedural backgrounds.

Features

  • Gravitational Lensing - Raymarched light bending around a Schwarzschild black hole
  • Accretion Disk - Temperature-based blackbody coloring with Keplerian differential rotation
  • Turbulence Patterns - FBM noise creates organic arc structures with cyclic animation
  • Procedural Background - Starfield and nebula clouds generated in the shader
  • Bloom Post-Processing - HDR bloom for enhanced glow effects
  • Real-time Controls - Tweakpane UI for adjusting all parameters

Live Demo

Visit: https://dgreenheck.github.io/webgpu-galaxy/

Requirements

  • Browser with WebGPU support (Chrome 113+, Edge 113+)
  • GPU with WebGPU capabilities

Getting Started

# Install dependencies
npm install

# Start development server
npm run dev

# Build for production
npm run build

Controls

  • Left Mouse Drag - Orbit camera
  • Right Mouse Drag - Pan camera
  • Mouse Wheel - Zoom in/out
  • Right Panel - Adjust parameters

Parameters

Black Hole

  • Mass and gravitational lensing strength
  • Disk geometry (inner/outer radius)
  • Disk appearance (temperature, brightness, opacity)
  • Turbulence (scale, stretch, rotation speed, cycle time)

Background

  • Star density, size, and brightness
  • Nebula layers with independent colors and density

Post-Processing

  • Bloom strength, radius, and threshold

Technical Details

The simulation uses a raymarching approach to trace light paths through curved spacetime around a Schwarzschild (non-rotating) black hole. Key techniques:

  • Adaptive step size near the event horizon for accurate light bending
  • Analytic disk intersection for efficient accretion disk rendering
  • Cyclic time crossfade prevents differential rotation from winding turbulence indefinitely
  • Blackbody radiation approximation for physically-motivated disk colors

License

MIT

Acknowledgments

Built with Three.js and WebGPU

Core symbols most depended-on inside this repo

catmullRom
called by 6
camera-animation.js
getKeyframe
called by 4
camera-animation.js
showNotification
called by 4
ui.js
updateUniforms
called by 3
blackhole.js
update
called by 3
blackhole.js
getBlackbodyColor
called by 2
blackhole-shader.js
createBlackHole
called by 2
blackhole.js
normalizeColorToHex
called by 2
main.js

Shape

Method 32
Function 13
Class 6

Languages

TypeScript100%

Modules by API surface

ui.js14 symbols
camera-animation.js14 symbols
blackhole.js11 symbols
main.js7 symbols
blackhole-shader.js5 symbols

For agents

$ claude mcp add webgpu-black-hole \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact