# ultrich-ea2/iterative-ray-tracing architecture

> Architecture diagram of the GitHub repository ultrich-ea2/iterative-ray-tracing, 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/ultrich-ea2/iterative-ray-tracing
- Repository: https://github.com/ultrich-ea2/iterative-ray-tracing

## Overview

This is an interactive C++ ray tracer: the application builds a scene and camera, renders pixels through a recursive ray-coloring loop, then displays the image and rerenders when keyboard input changes the camera. Rendering includes parallel workers, adaptive sampling, and scaled previews; scene geometry includes spheres, boxes, and the split box, with textured and reflective/refractive materials. The graph follows the shown calls and documented capabilities; unsampled headers are included where the README and source index establish their role, but their internal behavior is not inferred.

Main entry points: [`src/main.cpp`](https://github.com/ultrich-ea2/iterative-ray-tracing/blob/main/src/main.cpp) (Scene and controls), [`include/camera.h`](https://github.com/ultrich-ea2/iterative-ray-tracing/blob/main/include/camera.h) (Camera rays), [`include/parallel_render.h`](https://github.com/ultrich-ea2/iterative-ray-tracing/blob/main/include/parallel_render.h) (Parallel scaled renderer), [`include/split_box.h`](https://github.com/ultrich-ea2/iterative-ray-tracing/blob/main/include/split_box.h) (Split box)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application"]
  node_application["Scene and controls<br/>[main.cpp]"]
end

subgraph group_render["Rendering"]
  node_raycolor["Recursive ray color<br/>[main.cpp]"]
  node_parallel["Parallel scaled renderer<br/>[parallel_render.h]"]
  node_camera["Camera rays<br/>[camera.h]"]
end

subgraph group_scene["Scene and geometry"]
  node_world["Scene object list<br/>[hittable_list.h]"]
  node_sphere["Sphere geometry<br/>[sphere.h]"]
  node_box["Box geometry<br/>[box.h]"]
  node_rect["Axis-aligned rectangles<br/>[aarect.h]"]
  node_splitbox["Split box<br/>[split_box.h]"]
end

subgraph group_shading["Shading"]
  node_material["Material scattering<br/>[material.h]"]
  node_texture["Color textures<br/>[texture.h]"]
end

subgraph group_foundation["Ray primitives"]
  node_hittable["Hit interface<br/>[hittable.h]"]
  node_ray["Ray representation<br/>[ray.h]"]
  node_vector["Vector math<br/>[vec3.h]"]
end

node_user(("Keyboard user"))
node_display["SDL display"]

node_user -->|"controls"| node_application
node_application -->|"builds scene"| node_world
node_application -->|"adds spheres"| node_sphere
node_application -->|"adds boxes"| node_box
node_application -->|"creates split box"| node_splitbox
node_application -->|"creates materials"| node_material
node_application -->|"creates textures"| node_texture
node_application -->|"configures camera"| node_camera
node_application -->|"requests rendering"| node_parallel
node_application -->|"updates image"| node_display
node_parallel -->|"generates rays"| node_camera
node_parallel -->|"shades rays"| node_raycolor
node_raycolor -->|"tests hits"| node_world
node_raycolor -->|"scatters hit"| node_material
node_camera -->|"constructs rays"| node_ray
node_world -->|"tests objects"| node_hittable
node_sphere -->|"implements hits"| node_hittable
node_box -->|"builds sides"| node_rect
node_splitbox -->|"builds upper half"| node_box
node_splitbox -->|"builds lower shell"| node_rect
node_material -->|"samples albedo"| node_texture
node_hittable -->|"receives rays"| node_ray
node_ray -->|"uses vectors"| node_vector
node_camera -->|"calculates directions"| node_vector
node_texture -->|"returns colors"| node_vector

click node_application "https://github.com/ultrich-ea2/iterative-ray-tracing/blob/main/src/main.cpp"
click node_raycolor "https://github.com/ultrich-ea2/iterative-ray-tracing/blob/main/src/main.cpp"
click node_parallel "https://github.com/ultrich-ea2/iterative-ray-tracing/blob/main/include/parallel_render.h"
click node_camera "https://github.com/ultrich-ea2/iterative-ray-tracing/blob/main/include/camera.h"
click node_world "https://github.com/ultrich-ea2/iterative-ray-tracing/blob/main/include/hittable_list.h"
click node_sphere "https://github.com/ultrich-ea2/iterative-ray-tracing/blob/main/include/sphere.h"
click node_box "https://github.com/ultrich-ea2/iterative-ray-tracing/blob/main/include/box.h"
click node_rect "https://github.com/ultrich-ea2/iterative-ray-tracing/blob/main/include/aarect.h"
click node_splitbox "https://github.com/ultrich-ea2/iterative-ray-tracing/blob/main/include/split_box.h"
click node_material "https://github.com/ultrich-ea2/iterative-ray-tracing/blob/main/include/material.h"
click node_texture "https://github.com/ultrich-ea2/iterative-ray-tracing/blob/main/include/texture.h"
click node_hittable "https://github.com/ultrich-ea2/iterative-ray-tracing/blob/main/include/hittable.h"
click node_ray "https://github.com/ultrich-ea2/iterative-ray-tracing/blob/main/include/ray.h"
click node_vector "https://github.com/ultrich-ea2/iterative-ray-tracing/blob/main/include/vec3.h"

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_application,node_user toneBlue
class node_raycolor,node_parallel,node_camera toneAmber
class node_world,node_sphere,node_box,node_rect,node_splitbox toneMint
class node_material,node_texture toneRose
class node_hittable,node_ray,node_vector,node_display toneIndigo
```

## Components

### Application

- [Scene and controls](https://github.com/ultrich-ea2/iterative-ray-tracing/blob/main/src/main.cpp): `src/main.cpp`

### Rendering

- [Recursive ray color](https://github.com/ultrich-ea2/iterative-ray-tracing/blob/main/src/main.cpp): `src/main.cpp`
- [Parallel scaled renderer](https://github.com/ultrich-ea2/iterative-ray-tracing/blob/main/include/parallel_render.h): `include/parallel_render.h`
- [Camera rays](https://github.com/ultrich-ea2/iterative-ray-tracing/blob/main/include/camera.h): `include/camera.h`

### Scene and geometry

- [Scene object list](https://github.com/ultrich-ea2/iterative-ray-tracing/blob/main/include/hittable_list.h): `include/hittable_list.h`
- [Sphere geometry](https://github.com/ultrich-ea2/iterative-ray-tracing/blob/main/include/sphere.h): `include/sphere.h`
- [Box geometry](https://github.com/ultrich-ea2/iterative-ray-tracing/blob/main/include/box.h): `include/box.h`
- [Axis-aligned rectangles](https://github.com/ultrich-ea2/iterative-ray-tracing/blob/main/include/aarect.h): `include/aarect.h`
- [Split box](https://github.com/ultrich-ea2/iterative-ray-tracing/blob/main/include/split_box.h): `include/split_box.h`

### Shading

- [Material scattering](https://github.com/ultrich-ea2/iterative-ray-tracing/blob/main/include/material.h): `include/material.h`
- [Color textures](https://github.com/ultrich-ea2/iterative-ray-tracing/blob/main/include/texture.h): `include/texture.h`

### Ray primitives

- [Hit interface](https://github.com/ultrich-ea2/iterative-ray-tracing/blob/main/include/hittable.h): `include/hittable.h`
- [Ray representation](https://github.com/ultrich-ea2/iterative-ray-tracing/blob/main/include/ray.h): `include/ray.h`
- [Vector math](https://github.com/ultrich-ea2/iterative-ray-tracing/blob/main/include/vec3.h): `include/vec3.h`

### Other components

- **Keyboard user**
- **SDL display**

## Connections

- Keyboard user → Scene and controls: controls (evidence: `src/main.cpp`)
- Scene and controls → Scene object list: builds scene (evidence: `src/main.cpp`)
- Scene and controls → Sphere geometry: adds spheres (evidence: `src/main.cpp`)
- Scene and controls → Box geometry: adds boxes (evidence: `src/main.cpp`)
- Scene and controls → Split box: creates split box (evidence: `src/main.cpp`)
- Scene and controls → Material scattering: creates materials (evidence: `src/main.cpp`)
- Scene and controls → Color textures: creates textures (evidence: `src/main.cpp`)
- Scene and controls → Camera rays: configures camera (evidence: `src/main.cpp`)
- Scene and controls → Parallel scaled renderer: requests rendering (evidence: `src/main.cpp`)
- Scene and controls → SDL display: updates image (evidence: `src/main.cpp`)
- Parallel scaled renderer → Camera rays: generates rays (evidence: `include/parallel_render.h`)
- Parallel scaled renderer → Recursive ray color: shades rays (evidence: `include/parallel_render.h`)
- Recursive ray color → Scene object list: tests hits (evidence: `src/main.cpp`)
- Recursive ray color → Material scattering: scatters hit (evidence: `src/main.cpp`)
- Camera rays → Ray representation: constructs rays (evidence: `include/camera.h`)
- Scene object list → Hit interface: tests objects (evidence: `include/hittable_list.h`)
- Sphere geometry → Hit interface: implements hits (evidence: `include/sphere.h`)
- Box geometry → Axis-aligned rectangles: builds sides (evidence: `include/box.h`)
- Split box → Box geometry: builds upper half (evidence: `include/split_box.h`)
- Split box → Axis-aligned rectangles: builds lower shell (evidence: `include/split_box.h`)
- Material scattering → Color textures: samples albedo (evidence: `include/material.h`)
- Hit interface → Ray representation: receives rays (evidence: `include/hittable.h`)
- Ray representation → Vector math: uses vectors (evidence: `include/ray.h`)
- Camera rays → Vector math: calculates directions (evidence: `include/camera.h`)
- Color textures → Vector math: returns colors (evidence: `include/texture.h`)
