# bollu/optics architecture

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

- Interactive diagram: https://gitdiagram.com/bollu/optics
- Repository: https://github.com/bollu/optics

## Overview

Optics is an interactive ray-marching demo for signed-distance-function lens optics. The main loop selects among five scenes with Tab/Shift-Tab; scenes respond to pointer and wheel input, trace rays through lens geometry, and render optical behavior. The README highlights defocus, aperture-versus-sharpness, and thin-versus-thick lens comparisons. The shared header defines SDF geometry and material queries. Scene files are represented as distinct demonstrations; raygui is not shown because the sampled runtime does not establish its use. Relationships are based on excerpts and README statements.

Main entry points: [`main.cpp`](https://github.com/bollu/optics/blob/main/main.cpp) (Window and Scene Loop), [`optics.h`](https://github.com/bollu/optics/blob/main/optics.h) (SDF Geometry and Materials), [`scenea.cpp`](https://github.com/bollu/optics/blob/main/scenea.cpp) (Lens Ray Tracing), [`sceneb.cpp`](https://github.com/bollu/optics/blob/main/sceneb.cpp) (Ray-Step Visualization)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application"]
  node_loop["Window and Scene Loop<br/>[main.cpp]"]
end

subgraph group_core["Optics Core"]
  node_geometry["SDF Geometry and Materials<br/>[optics.h]"]
end

subgraph group_demos["Optics Demonstrations"]
  node_scene_a["Lens Ray Tracing<br/>[scenea.cpp]"]
  node_scene_b["Ray-Step Visualization<br/>[sceneb.cpp]"]
  node_scene_c["Importance Sampling<br/>[scenec.cpp]"]
  node_scene_d["Aperture and Screen<br/>[scened.cpp]"]
  node_scene_f["Exposure and Depth of Field<br/>[scenef.cpp]"]
end

node_user(("Viewer"))

node_user -->|"select scene"| node_loop
node_loop -->|"dispatches"| node_scene_a
node_loop -->|"dispatches"| node_scene_b
node_loop -->|"dispatches"| node_scene_c
node_loop -->|"dispatches"| node_scene_d
node_loop -->|"dispatches"| node_scene_f
node_scene_a -->|"queries SDF"| node_geometry
node_scene_b -->|"queries SDF"| node_geometry
node_scene_c -->|"queries SDF"| node_geometry
node_scene_d -->|"queries SDF"| node_geometry
node_scene_f -->|"queries SDF"| node_geometry

click node_loop "https://github.com/bollu/optics/blob/main/main.cpp"
click node_geometry "https://github.com/bollu/optics/blob/main/optics.h"
click node_scene_a "https://github.com/bollu/optics/blob/main/scenea.cpp"
click node_scene_b "https://github.com/bollu/optics/blob/main/sceneb.cpp"
click node_scene_c "https://github.com/bollu/optics/blob/main/scenec.cpp"
click node_scene_d "https://github.com/bollu/optics/blob/main/scened.cpp"
click node_scene_f "https://github.com/bollu/optics/blob/main/scenef.cpp"

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_loop,node_user toneBlue
class node_geometry toneAmber
class node_scene_a,node_scene_b,node_scene_c,node_scene_d,node_scene_f toneMint
```

## Components

### Application

- [Window and Scene Loop](https://github.com/bollu/optics/blob/main/main.cpp): `main.cpp`

### Optics Core

- [SDF Geometry and Materials](https://github.com/bollu/optics/blob/main/optics.h): `optics.h`

### Optics Demonstrations

- [Lens Ray Tracing](https://github.com/bollu/optics/blob/main/scenea.cpp): `scenea.cpp`
- [Ray-Step Visualization](https://github.com/bollu/optics/blob/main/sceneb.cpp): `sceneb.cpp`
- [Importance Sampling](https://github.com/bollu/optics/blob/main/scenec.cpp): `scenec.cpp`
- [Aperture and Screen](https://github.com/bollu/optics/blob/main/scened.cpp): `scened.cpp`
- [Exposure and Depth of Field](https://github.com/bollu/optics/blob/main/scenef.cpp): `scenef.cpp`

### Other components

- **Viewer**

## Connections

- Viewer → Window and Scene Loop: select scene (evidence: `main.cpp`)
- Window and Scene Loop → Lens Ray Tracing: dispatches (evidence: `main.cpp`)
- Window and Scene Loop → Ray-Step Visualization: dispatches (evidence: `main.cpp`)
- Window and Scene Loop → Importance Sampling: dispatches (evidence: `main.cpp`)
- Window and Scene Loop → Aperture and Screen: dispatches (evidence: `main.cpp`)
- Window and Scene Loop → Exposure and Depth of Field: dispatches (evidence: `main.cpp`)
- Lens Ray Tracing → SDF Geometry and Materials: queries SDF (evidence: `scenea.cpp`)
- Ray-Step Visualization → SDF Geometry and Materials: queries SDF (evidence: `sceneb.cpp`)
- Importance Sampling → SDF Geometry and Materials: queries SDF (evidence: `scenec.cpp`)
- Aperture and Screen → SDF Geometry and Materials: queries SDF (evidence: `scened.cpp`)
- Exposure and Depth of Field → SDF Geometry and Materials: queries SDF (evidence: `scenef.cpp`)
