# deankjones/raytracer architecture

> Architecture diagram of the GitHub repository deankjones/raytracer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-02-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/deankjones/raytracer
- Repository: https://github.com/deankjones/raytracer

## Overview

##### Project Type Analysis
This is a graphics application, specifically a ray tracer, built with C++ using Vulkan and various graphics-related libraries. It's a desktop application with a GUI component using ImGui.

##### Main Architectural Components

a. Application Layer:
- Core Application Framework
- GUI System (ImGui-based)
- Input Handling

b. Ray Tracing Engine:
- Scene Management
- Rendering Pipeline
- Camera System
- Material System
- Object System

c. Acceleration Structures:
- BVH (Bounding Volume Hierarchy)

d. External Dependencies:
- Vulkan
- GLFW
- GLM
- ImGui
- STB Image

**┌─────────────────────────────────────────────────────────┐**
- Application Layer                      │
- ┌─────────────┐  ┌──────────────┐  ┌──────────────┐   │
- ImGui    │  │Input Handling│  │    Timer     │   │
- ┘  └──────────────┘  └──────────────┘   │
- ┘
- ▼
**┌─────────────────────────────────────────────────────────┐**
- Ray Tracing Engine Core                   │
- ┌─────────────┐  ┌──────────────┐  ┌──────────────┐   │
- Scene     │  │   Camera     │  │   Render     │   │
- ┘  └──────────────┘  └──────────────┘   │
- ┌─────────────┐  ┌──────────────┐                     │
- Objects   │  │  Materials   │                     │
- ┘  └──────────────┘                     │
- ┘
- ▼
**┌─────────────────────────────────────────────────────────┐**
- Acceleration Structures                  │
- ┌─────────────────────────────────────────────────┐   │
- BVH                        │   │
- ┘   │
- ┘

##### Component Relationships
- Data flow between components
- Inheritance relationships (particularly in the object system)
- Dependencies between modules

##### Specific Implementation Details

Key architectural elements:
- Ray tracing pipeline flow
- Scene graph structure
- Material system hierarchy
- Object system with primitives (Sphere, Triangle, etc.)
- BVH acceleration structure integration

##### Important Notes

- Parallel processing capability (indicated by the Parallel.cpp file)
- PDF (Probability Density Function) system for materials
- Various shading models (Lambertian, Metal, Dielectric)
- Mesh loading and processing pipeline
- Random number generation system's integration

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef application fill:#2196F3,stroke:#1565C0,color:white
    classDef rendering fill:#4CAF50,stroke:#388E3C,color:white
    classDef acceleration fill:#FF9800,stroke:#F57C00,color:white
    classDef external fill:#9E9E9E,stroke:#616161,color:white
    classDef shading fill:#8BC34A,stroke:#689F38,color:white
    classDef primitive fill:#00BCD4,stroke:#0097A7,color:white

    subgraph Application
        App[Application Framework]
        GUI[GUI System]
        Input[Input Handler]
        Timer[Timer System]
        Random[Random Generator]
        Parallel[Parallel Processing]
    end

    subgraph RayTracingEngine
        Scene[Scene Management]
        Camera[Camera System]
        Render[Rendering Pipeline]
        
        subgraph MaterialSystem
            Material[Material System]
            PDF[PDF System]
            Lambertian[Lambertian]
            Metal[Metal]
            Dielectric[Dielectric]
        end
        
        subgraph ObjectSystem
            Objects[Object System]
            Primitive[Primitive Objects]
            Mesh[Mesh Loading]
        end
    end

    subgraph AccelerationStructures
        BVH[BVH System]
    end

    subgraph ExternalDeps
        Vulkan[Vulkan]
        GLFW[GLFW]
        GLM[GLM]
        ImGui[ImGui]
        STB[STB Image]
    end

    %% Relationships
    App --> Scene
    App --> GUI
    App --> Input
    Scene --> Camera
    Scene --> Render
    Scene --> Objects
    Objects --> BVH
    Objects --> Primitive
    Objects --> Mesh
    Render --> Material
    Material --> PDF
    Material --> Lambertian
    Material --> Metal
    Material --> Dielectric
    App --> Random
    App --> Parallel
    App --> Timer

    %% External Dependencies
    App --> Vulkan
    App --> GLFW
    GUI --> ImGui
    Mesh --> STB
    App --> GLM

    %% Click Events
    click App "https://github.com/DeanKJones/RayTracer/blob/master/core/src/Application.h"
    click GUI "https://github.com/DeanKJones/RayTracer/tree/master/core/ImGui/"
    click Input "https://github.com/DeanKJones/RayTracer/tree/master/core/src/input/"
    click Scene "https://github.com/DeanKJones/RayTracer/blob/master/app/src/Scene.h"
    click Camera "https://github.com/DeanKJones/RayTracer/blob/master/app/src/Camera.h"
    click Render "https://github.com/DeanKJones/RayTracer/blob/master/app/src/Render.h"
    click Material "https://github.com/DeanKJones/RayTracer/tree/master/app/src/shading/"
    click Objects "https://github.com/DeanKJones/RayTracer/tree/master/app/src/obj/"
    click BVH "https://github.com/DeanKJones/RayTracer/tree/master/app/src/obj/bvh/"
    click PDF "https://github.com/DeanKJones/RayTracer/tree/master/app/src/pdf/"
    click Primitive "https://github.com/DeanKJones/RayTracer/tree/master/app/src/obj/primitive/"
    click Lambertian "https://github.com/DeanKJones/RayTracer/blob/master/app/src/shading/Lambertian.h"
    click Metal "https://github.com/DeanKJones/RayTracer/blob/master/app/src/shading/Metal.h"
    click Dielectric "https://github.com/DeanKJones/RayTracer/blob/master/app/src/shading/Dielectric.h"
    click Parallel "https://github.com/DeanKJones/RayTracer/blob/master/core/src/Parallel.h"
    click Random "https://github.com/DeanKJones/RayTracer/blob/master/core/src/Random.h"
    click Timer "https://github.com/DeanKJones/RayTracer/blob/master/core/src/Timer.h"

    %% Style Applications
    class App,GUI,Input,Timer,Random,Parallel application
    class Scene,Camera,Render rendering
    class BVH acceleration
    class Vulkan,GLFW,GLM,ImGui,STB external
    class Material,PDF,Lambertian,Metal,Dielectric shading
    class Objects,Primitive,Mesh primitive
```
