# bigmat18/ocl-path-tracing architecture

> Architecture diagram of the GitHub repository bigmat18/ocl-path-tracing, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bigmat18/ocl-path-tracing
- Repository: https://github.com/bigmat18/ocl-path-tracing

## Overview

This is a small C++ path-tracing renderer: it builds a sphere scene, samples camera rays per pixel, traces recursive material scattering, and writes a PPM image to standard output. The graph separates scene geometry, rendering, materials, and math support. Relationships are based on the sampled source; the README is empty, and no OpenCL or graphics-runtime workflow is visible in the excerpts.

Main entry points: [`source/main.cpp`](https://github.com/bigmat18/ocl-path-tracing/blob/main/source/main.cpp) (Render Entry), [`source/random.h`](https://github.com/bigmat18/ocl-path-tracing/blob/main/source/random.h) (Random Sampling), [`source/materials.hpp`](https://github.com/bigmat18/ocl-path-tracing/blob/main/source/materials.hpp) (Scatter Interface), [`source/sphere.hpp`](https://github.com/bigmat18/ocl-path-tracing/blob/main/source/sphere.hpp) (Sphere Geometry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_render["Rendering"]
  node_entry["Render Entry<br/>[main.cpp]"]
  node_tracer["Ray Tracer<br/>[main.cpp]"]
  node_camera["Camera Sampling<br/>[common.hpp]"]
  node_image["PPM Output<br/>[common.hpp]"]
end

subgraph group_scene["Scene Geometry"]
  node_hittable["Hit Interface<br/>[hittable.hpp]"]
  node_sphere["Sphere Geometry<br/>[sphere.hpp]"]
end

subgraph group_materials["Materials"]
  node_material["Scatter Interface<br/>[materials.hpp]"]
  node_diffuse["Diffuse Material<br/>[materials.hpp]"]
  node_metal["Metal Material<br/>[materials.hpp]"]
  node_dielectric["Dielectric Material<br/>[materials.hpp]"]
end

subgraph group_math["Math Support"]
  node_random["Random Sampling<br/>[random.h]"]
  node_vector["Vector Math<br/>[vector.hpp]"]
  node_matrix["Matrix Math<br/>[matrix.hpp]"]
  node_tensor["Tensor Operations<br/>[tensor.hpp]"]
  node_color["Packed Color<br/>[color.hpp]"]
end

node_user(("User"))

node_user -->|"runs"| node_entry
node_entry -->|"requests rays"| node_camera
node_entry -->|"traces samples"| node_tracer
node_entry -->|"builds scene"| node_sphere
node_entry -->|"creates materials"| node_diffuse
node_entry -->|"creates materials"| node_metal
node_entry -->|"creates materials"| node_dielectric
node_tracer -->|"tests hits"| node_hittable
node_tracer -->|"scatters rays"| node_material
node_tracer -->|"recurses"| node_tracer
node_tracer -->|"returns color"| node_image
node_entry -->|"writes pixels"| node_image
node_sphere -->|"implements"| node_hittable
node_diffuse -->|"implements"| node_material
node_metal -->|"implements"| node_material
node_dielectric -->|"implements"| node_material
node_camera -->|"samples jitter"| node_random
node_diffuse -->|"samples scatter"| node_random
node_metal -->|"samples fuzz"| node_random
node_vector -->|"extends"| node_matrix
node_matrix -->|"extends"| node_tensor
node_sphere -->|"uses vectors"| node_vector
node_random -->|"generates vectors"| node_vector

click node_entry "https://github.com/bigmat18/ocl-path-tracing/blob/main/source/main.cpp"
click node_tracer "https://github.com/bigmat18/ocl-path-tracing/blob/main/source/main.cpp"
click node_camera "https://github.com/bigmat18/ocl-path-tracing/blob/main/source/common.hpp"
click node_image "https://github.com/bigmat18/ocl-path-tracing/blob/main/source/common.hpp"
click node_hittable "https://github.com/bigmat18/ocl-path-tracing/blob/main/source/hittable.hpp"
click node_sphere "https://github.com/bigmat18/ocl-path-tracing/blob/main/source/sphere.hpp"
click node_material "https://github.com/bigmat18/ocl-path-tracing/blob/main/source/materials.hpp"
click node_diffuse "https://github.com/bigmat18/ocl-path-tracing/blob/main/source/materials.hpp"
click node_metal "https://github.com/bigmat18/ocl-path-tracing/blob/main/source/materials.hpp"
click node_dielectric "https://github.com/bigmat18/ocl-path-tracing/blob/main/source/materials.hpp"
click node_random "https://github.com/bigmat18/ocl-path-tracing/blob/main/source/random.h"
click node_vector "https://github.com/bigmat18/ocl-path-tracing/blob/main/source/math/vector.hpp"
click node_matrix "https://github.com/bigmat18/ocl-path-tracing/blob/main/source/math/matrix.hpp"
click node_tensor "https://github.com/bigmat18/ocl-path-tracing/blob/main/source/math/tensor.hpp"
click node_color "https://github.com/bigmat18/ocl-path-tracing/blob/main/source/math/color.hpp"

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_entry,node_tracer,node_camera,node_image,node_user toneBlue
class node_hittable,node_sphere toneAmber
class node_material,node_diffuse,node_metal,node_dielectric toneMint
class node_random,node_vector,node_matrix,node_tensor,node_color toneRose
```

## Components

### Rendering

- [Render Entry](https://github.com/bigmat18/ocl-path-tracing/blob/main/source/main.cpp): `source/main.cpp`
- [Ray Tracer](https://github.com/bigmat18/ocl-path-tracing/blob/main/source/main.cpp): `source/main.cpp`
- [Camera Sampling](https://github.com/bigmat18/ocl-path-tracing/blob/main/source/common.hpp): `source/common.hpp`
- [PPM Output](https://github.com/bigmat18/ocl-path-tracing/blob/main/source/common.hpp): `source/common.hpp`

### Scene Geometry

- [Hit Interface](https://github.com/bigmat18/ocl-path-tracing/blob/main/source/hittable.hpp): `source/hittable.hpp`
- [Sphere Geometry](https://github.com/bigmat18/ocl-path-tracing/blob/main/source/sphere.hpp): `source/sphere.hpp`

### Materials

- [Scatter Interface](https://github.com/bigmat18/ocl-path-tracing/blob/main/source/materials.hpp): `source/materials.hpp`
- [Diffuse Material](https://github.com/bigmat18/ocl-path-tracing/blob/main/source/materials.hpp): `source/materials.hpp`
- [Metal Material](https://github.com/bigmat18/ocl-path-tracing/blob/main/source/materials.hpp): `source/materials.hpp`
- [Dielectric Material](https://github.com/bigmat18/ocl-path-tracing/blob/main/source/materials.hpp): `source/materials.hpp`

### Math Support

- [Random Sampling](https://github.com/bigmat18/ocl-path-tracing/blob/main/source/random.h): `source/random.h`
- [Vector Math](https://github.com/bigmat18/ocl-path-tracing/blob/main/source/math/vector.hpp): `source/math/vector.hpp`
- [Matrix Math](https://github.com/bigmat18/ocl-path-tracing/blob/main/source/math/matrix.hpp): `source/math/matrix.hpp`
- [Tensor Operations](https://github.com/bigmat18/ocl-path-tracing/blob/main/source/math/tensor.hpp): `source/math/tensor.hpp`
- [Packed Color](https://github.com/bigmat18/ocl-path-tracing/blob/main/source/math/color.hpp): `source/math/color.hpp`

### Other components

- **User**

## Connections

- User → Render Entry: runs (evidence: `source/main.cpp`)
- Render Entry → Camera Sampling: requests rays (evidence: `source/main.cpp`)
- Render Entry → Ray Tracer: traces samples (evidence: `source/main.cpp`)
- Render Entry → Sphere Geometry: builds scene (evidence: `source/main.cpp`)
- Render Entry → Diffuse Material: creates materials (evidence: `source/main.cpp`)
- Render Entry → Metal Material: creates materials (evidence: `source/main.cpp`)
- Render Entry → Dielectric Material: creates materials (evidence: `source/main.cpp`)
- Ray Tracer → Hit Interface: tests hits (evidence: `source/main.cpp`)
- Ray Tracer → Scatter Interface: scatters rays (evidence: `source/main.cpp`)
- Ray Tracer → Ray Tracer: recurses (evidence: `source/main.cpp`)
- Ray Tracer → PPM Output: returns color (evidence: `source/main.cpp`)
- Render Entry → PPM Output: writes pixels (evidence: `source/main.cpp`)
- Sphere Geometry → Hit Interface: implements (evidence: `source/sphere.hpp`)
- Diffuse Material → Scatter Interface: implements (evidence: `source/materials.hpp`)
- Metal Material → Scatter Interface: implements (evidence: `source/materials.hpp`)
- Dielectric Material → Scatter Interface: implements (evidence: `source/materials.hpp`)
- Camera Sampling → Random Sampling: samples jitter (evidence: `source/common.hpp`)
- Diffuse Material → Random Sampling: samples scatter (evidence: `source/materials.hpp`)
- Metal Material → Random Sampling: samples fuzz (evidence: `source/materials.hpp`)
- Vector Math → Matrix Math: extends (evidence: `source/math/vector.hpp`)
- Matrix Math → Tensor Operations: extends (evidence: `source/math/matrix.hpp`)
- Sphere Geometry → Vector Math: uses vectors (evidence: `source/sphere.hpp`)
- Random Sampling → Vector Math: generates vectors (evidence: `source/random.h`)
