# lepsima/black-hole-simulation architecture

> Architecture diagram of the GitHub repository lepsima/black-hole-simulation, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lepsima/black-hole-simulation
- Repository: https://github.com/lepsima/black-hole-simulation

## Overview

BlackHoles is an interactive C#/HLSL black-hole renderer. The main workflow starts with user input and camera movement, dispatches a per-pixel compute-shader simulation, applies bloom, and draws the result and menu. A separate video-render mode interpolates between camera positions and saves rendered frames. The README also describes configurable disk and ray-tracing behavior; those simulation details are documented, but the shader implementation was not excerpted. Edges reflect shown calls, source-index references, or README statements.

Main entry points: [`Core/Core.cs`](https://github.com/lepsima/black-hole-simulation/blob/master/Core/Core.cs) (Game coordinator), [`Core/FrameRenderer.cs`](https://github.com/lepsima/black-hole-simulation/blob/master/Core/FrameRenderer.cs) (Frame renderer), [`Systems/BloomFilter.cs`](https://github.com/lepsima/black-hole-simulation/blob/master/Systems/BloomFilter.cs) (Bloom filter), [`Core/Camera.cs`](https://github.com/lepsima/black-hole-simulation/blob/master/Core/Camera.cs) (Camera state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application"]
  node_program["Application entry<br/>[Program.cs]"]
  node_core["Game coordinator<br/>[Core.cs]"]
  node_stats["Frame statistics<br/>[FrameStats.cs]"]
end

subgraph group_simulation["Simulation"]
  node_ray["Ray simulation<br/>[BlackHole.cs]"]
  node_shader["Ray compute shader<br/>[BlackHole.fx]"]
end

subgraph group_render["Rendering"]
  node_frame["Frame renderer<br/>[FrameRenderer.cs]"]
  node_bloom["Bloom filter<br/>[BloomFilter.cs]"]
  node_bloomshader["Bloom shader<br/>[Bloom.fx]"]
  node_quad["Quad renderer<br/>[QuadRenderer.cs]"]
  node_text["Menu renderer<br/>[TextRenderer.cs]"]
  node_frames["Rendered frame files"]
end

subgraph group_controls["Controls and settings"]
  node_camera["Camera state<br/>[Camera.cs]"]
  node_input["Keyboard input<br/>[InputHandler.cs]"]
  node_settings["Settings files<br/>[Settings.cs]"]
  node_configurable["Settings refresh<br/>[Configurable.cs]"]
end

node_user(("User"))

node_user -->|"presses keys"| node_input
node_program -->|"starts game"| node_core
node_core -->|"registers handlers"| node_input
node_core -->|"updates"| node_camera
node_core -->|"draws frames"| node_frame
node_core -->|"updates stats"| node_stats
node_core -->|"loads settings"| node_settings
node_core -->|"applies settings"| node_configurable
node_frame -->|"reads camera"| node_camera
node_frame -->|"renders simulation"| node_ray
node_ray -->|"dispatches compute"| node_shader
node_frame -->|"applies bloom"| node_bloom
node_bloom -->|"loads effect"| node_bloomshader
node_bloom -->|"renders passes"| node_quad
node_frame -->|"draws menu"| node_text
node_core -->|"loads renderer"| node_text
node_core -->|"updates controls"| node_camera
node_frame -->|"writes images"| node_frames

click node_program "https://github.com/lepsima/black-hole-simulation/blob/master/Program.cs"
click node_core "https://github.com/lepsima/black-hole-simulation/blob/master/Core/Core.cs"
click node_camera "https://github.com/lepsima/black-hole-simulation/blob/master/Core/Camera.cs"
click node_input "https://github.com/lepsima/black-hole-simulation/blob/master/Systems/InputHandler.cs"
click node_settings "https://github.com/lepsima/black-hole-simulation/blob/master/Core/Settings.cs"
click node_configurable "https://github.com/lepsima/black-hole-simulation/blob/master/Systems/Configurable.cs"
click node_ray "https://github.com/lepsima/black-hole-simulation/blob/master/Core/BlackHole.cs"
click node_shader "https://github.com/lepsima/black-hole-simulation/blob/master/Content/BlackHole.fx"
click node_frame "https://github.com/lepsima/black-hole-simulation/blob/master/Core/FrameRenderer.cs"
click node_bloom "https://github.com/lepsima/black-hole-simulation/blob/master/Systems/BloomFilter.cs"
click node_bloomshader "https://github.com/lepsima/black-hole-simulation/blob/master/Content/Bloom.fx"
click node_quad "https://github.com/lepsima/black-hole-simulation/blob/master/Systems/QuadRenderer.cs"
click node_text "https://github.com/lepsima/black-hole-simulation/blob/master/Systems/TextRenderer.cs"
click node_stats "https://github.com/lepsima/black-hole-simulation/blob/master/Systems/FrameStats.cs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_program,node_core,node_stats,node_user toneBlue
class node_ray,node_shader toneAmber
class node_frame,node_bloom,node_bloomshader,node_quad,node_text,node_frames toneMint
class node_camera,node_input,node_settings,node_configurable toneRose
```

## Components

### Application

- [Application entry](https://github.com/lepsima/black-hole-simulation/blob/master/Program.cs): `Program.cs`
- [Game coordinator](https://github.com/lepsima/black-hole-simulation/blob/master/Core/Core.cs): `Core/Core.cs`
- [Frame statistics](https://github.com/lepsima/black-hole-simulation/blob/master/Systems/FrameStats.cs): `Systems/FrameStats.cs`

### Simulation

- [Ray simulation](https://github.com/lepsima/black-hole-simulation/blob/master/Core/BlackHole.cs): `Core/BlackHole.cs`
- [Ray compute shader](https://github.com/lepsima/black-hole-simulation/blob/master/Content/BlackHole.fx): `Content/BlackHole.fx`

### Rendering

- [Frame renderer](https://github.com/lepsima/black-hole-simulation/blob/master/Core/FrameRenderer.cs): `Core/FrameRenderer.cs`
- [Bloom filter](https://github.com/lepsima/black-hole-simulation/blob/master/Systems/BloomFilter.cs): `Systems/BloomFilter.cs`
- [Bloom shader](https://github.com/lepsima/black-hole-simulation/blob/master/Content/Bloom.fx): `Content/Bloom.fx`
- [Quad renderer](https://github.com/lepsima/black-hole-simulation/blob/master/Systems/QuadRenderer.cs): `Systems/QuadRenderer.cs`
- [Menu renderer](https://github.com/lepsima/black-hole-simulation/blob/master/Systems/TextRenderer.cs): `Systems/TextRenderer.cs`
- **Rendered frame files**

### Controls and settings

- [Camera state](https://github.com/lepsima/black-hole-simulation/blob/master/Core/Camera.cs): `Core/Camera.cs`
- [Keyboard input](https://github.com/lepsima/black-hole-simulation/blob/master/Systems/InputHandler.cs): `Systems/InputHandler.cs`
- [Settings files](https://github.com/lepsima/black-hole-simulation/blob/master/Core/Settings.cs): `Core/Settings.cs`
- [Settings refresh](https://github.com/lepsima/black-hole-simulation/blob/master/Systems/Configurable.cs): `Systems/Configurable.cs`

### Other components

- **User**

## Connections

- User → Keyboard input: presses keys
- Application entry → Game coordinator: starts game (evidence: `Program.cs`)
- Game coordinator → Keyboard input: registers handlers (evidence: `Core/Core.cs`)
- Game coordinator → Camera state: updates (evidence: `Core/Core.cs`)
- Game coordinator → Frame renderer: draws frames (evidence: `Core/Core.cs`)
- Game coordinator → Frame statistics: updates stats (evidence: `Core/Core.cs`)
- Game coordinator → Settings files: loads settings (evidence: `Core/Core.cs`)
- Game coordinator → Settings refresh: applies settings (evidence: `Core/Core.cs`)
- Frame renderer → Camera state: reads camera (evidence: `Core/FrameRenderer.cs`)
- Frame renderer → Ray simulation: renders simulation (evidence: `Core/FrameRenderer.cs`)
- Ray simulation → Ray compute shader: dispatches compute (evidence: `Core/BlackHole.cs`)
- Frame renderer → Bloom filter: applies bloom (evidence: `Core/FrameRenderer.cs`)
- Bloom filter → Bloom shader: loads effect (evidence: `Systems/BloomFilter.cs`)
- Bloom filter → Quad renderer: renders passes (evidence: `Systems/BloomFilter.cs`)
- Frame renderer → Menu renderer: draws menu (evidence: `Core/FrameRenderer.cs`)
- Game coordinator → Menu renderer: loads renderer (evidence: `Core/Core.cs`)
- Game coordinator → Camera state: updates controls (evidence: `Core/Core.cs`)
- Frame renderer → Rendered frame files: writes images (evidence: `Core/FrameRenderer.cs`)
