# lofi-fx/spectra architecture

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

- Interactive diagram: https://gitdiagram.com/lofi-fx/spectra
- Repository: https://github.com/lofi-fx/spectra

## Overview

Spectra is an OFX film-emulation and finishing plugin for DaVinci Resolve. The workflow is: an editor supplies footage and effect settings in the host; the plugin applies film response and finishing controls through GPU rendering; the processed image returns to the host. The README also describes grain, halation, split toning, optical diffusion, printer points, and colour-space transforms. The excerpts establish the shared parameter and data structures, LUT and preset parsing, and GPU interfaces; some rendering-call details are not shown, so those links are omitted or marked unverified.

Main entry points: [`src/LowFiFxPlugin.cpp`](https://github.com/lofi-fx/spectra/blob/main/src/LowFiFxPlugin.cpp) (OFX Effect), [`src/MetalKernels.h`](https://github.com/lofi-fx/spectra/blob/main/src/MetalKernels.h) (Metal Renderer), [`src/CudaKernels.h`](https://github.com/lofi-fx/spectra/blob/main/src/CudaKernels.h) (CUDA Interface), [`src/LutPack.h`](https://github.com/lofi-fx/spectra/blob/main/src/LutPack.h) (Packed LUT Reader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_plugin["OFX Plugin"]
  node_plugin["OFX Effect<br/>[LowFiFxPlugin.cpp]"]
  node_controls["Effect Controls<br/>[LowFiFxPlugin.cpp]"]
  node_finishing["Finishing Effects<br/>[LowFiFxPlugin.cpp]"]
end

subgraph group_film["Film Data"]
  node_filmdata["Film Data Loader<br/>[SpectralFilmData.h]"]
  node_stockassets["Film Stock Assets"]
end

subgraph group_looks["Looks And Presets"]
  node_lutpack["Packed LUT Reader<br/>[LutPack.h]"]
  node_cubeparser["Cube LUT Parser<br/>[CubeParser.h]"]
  node_lutassets["Colour LUT Assets"]
  node_presetparser["Preset Reader<br/>[PresetParser.cpp]"]
end

subgraph group_compute["GPU Rendering"]
  node_grainparams["Render Parameters<br/>[GrainParams.h]"]
  node_metal["Metal Renderer<br/>[MetalKernels.h]"]
  node_metalcode["Metal Kernel Source"]
  node_cuda["CUDA Interface<br/>[CudaKernels.h]"]
  node_cudaimpl["CUDA Stubs<br/>[CudaKernels.cpp]"]
end

node_editor(("Editor"))
node_resolve["DaVinci Resolve"]

node_editor -->|"edits footage"| node_resolve
node_resolve -->|"hosts effect"| node_plugin
node_plugin -->|"defines controls"| node_controls
node_plugin -->|"builds parameters"| node_grainparams
node_plugin -.->|"applies effects"| node_finishing
node_plugin -->|"references data"| node_filmdata
node_filmdata -.->|"loads records"| node_stockassets
node_plugin -->|"references LUT reader"| node_lutpack
node_lutpack -->|"converts LUTs"| node_cubeparser
node_plugin -->|"references presets"| node_presetparser
node_plugin -.->|"dispatches rendering"| node_metal
node_plugin -.->|"selects backend"| node_cuda
node_cuda -->|"implemented by"| node_cudaimpl
node_metal -->|"consumes parameters"| node_grainparams
node_cuda -->|"consumes parameters"| node_grainparams
node_metal -.->|"uses kernels"| node_metalcode
node_plugin -.->|"returns processed image"| node_resolve
node_lutassets -.->|"packed at build time"| node_lutpack

click node_plugin "https://github.com/lofi-fx/spectra/blob/main/src/LowFiFxPlugin.cpp"
click node_controls "https://github.com/lofi-fx/spectra/blob/main/src/LowFiFxPlugin.cpp"
click node_grainparams "https://github.com/lofi-fx/spectra/blob/main/src/GrainParams.h"
click node_finishing "https://github.com/lofi-fx/spectra/blob/main/src/LowFiFxPlugin.cpp"
click node_filmdata "https://github.com/lofi-fx/spectra/blob/main/src/SpectralFilmData.h"
click node_stockassets "https://github.com/lofi-fx/spectra/tree/main/Resources/spectral_film_data"
click node_lutpack "https://github.com/lofi-fx/spectra/blob/main/src/LutPack.h"
click node_cubeparser "https://github.com/lofi-fx/spectra/blob/main/src/CubeParser.h"
click node_lutassets "https://github.com/lofi-fx/spectra/tree/main/LUTs"
click node_presetparser "https://github.com/lofi-fx/spectra/blob/main/src/PresetParser.cpp"
click node_metal "https://github.com/lofi-fx/spectra/blob/main/src/MetalKernels.h"
click node_metalcode "https://github.com/lofi-fx/spectra/blob/main/src/MetalKernelSource.h"
click node_cuda "https://github.com/lofi-fx/spectra/blob/main/src/CudaKernels.h"
click node_cudaimpl "https://github.com/lofi-fx/spectra/blob/main/src/CudaKernels.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_plugin,node_controls,node_finishing toneBlue
class node_filmdata,node_stockassets toneAmber
class node_lutpack,node_cubeparser,node_lutassets,node_presetparser toneMint
class node_grainparams,node_metal,node_metalcode,node_cuda,node_cudaimpl toneRose
class node_editor,node_resolve toneIndigo
```

## Components

### OFX Plugin

- [OFX Effect](https://github.com/lofi-fx/spectra/blob/main/src/LowFiFxPlugin.cpp): `src/LowFiFxPlugin.cpp`
- [Effect Controls](https://github.com/lofi-fx/spectra/blob/main/src/LowFiFxPlugin.cpp): `src/LowFiFxPlugin.cpp`
- [Finishing Effects](https://github.com/lofi-fx/spectra/blob/main/src/LowFiFxPlugin.cpp): `src/LowFiFxPlugin.cpp`

### Film Data

- [Film Data Loader](https://github.com/lofi-fx/spectra/blob/main/src/SpectralFilmData.h): `src/SpectralFilmData.h`
- [Film Stock Assets](https://github.com/lofi-fx/spectra/tree/main/Resources/spectral_film_data): `Resources/spectral_film_data`

### Looks And Presets

- [Packed LUT Reader](https://github.com/lofi-fx/spectra/blob/main/src/LutPack.h): `src/LutPack.h`
- [Cube LUT Parser](https://github.com/lofi-fx/spectra/blob/main/src/CubeParser.h): `src/CubeParser.h`
- [Colour LUT Assets](https://github.com/lofi-fx/spectra/tree/main/LUTs): `LUTs`
- [Preset Reader](https://github.com/lofi-fx/spectra/blob/main/src/PresetParser.cpp): `src/PresetParser.cpp`

### GPU Rendering

- [Render Parameters](https://github.com/lofi-fx/spectra/blob/main/src/GrainParams.h): `src/GrainParams.h`
- [Metal Renderer](https://github.com/lofi-fx/spectra/blob/main/src/MetalKernels.h): `src/MetalKernels.h`
- [Metal Kernel Source](https://github.com/lofi-fx/spectra/blob/main/src/MetalKernelSource.h): `src/MetalKernelSource.h`
- [CUDA Interface](https://github.com/lofi-fx/spectra/blob/main/src/CudaKernels.h): `src/CudaKernels.h`
- [CUDA Stubs](https://github.com/lofi-fx/spectra/blob/main/src/CudaKernels.cpp): `src/CudaKernels.cpp`

### Other components

- **Editor**
- **DaVinci Resolve**

## Connections

- Editor → DaVinci Resolve: edits footage (evidence: `README.md`)
- DaVinci Resolve → OFX Effect: hosts effect (evidence: `README.md`)
- OFX Effect → Effect Controls: defines controls (evidence: `src/LowFiFxPlugin.cpp`)
- OFX Effect → Render Parameters: builds parameters (evidence: `src/LowFiFxPlugin.cpp`)
- OFX Effect → Finishing Effects: applies effects (evidence: `src/LowFiFxPlugin.cpp`)
- OFX Effect → Film Data Loader: references data (evidence: `src/LowFiFxPlugin.cpp`)
- Film Data Loader → Film Stock Assets: loads records
- OFX Effect → Packed LUT Reader: references LUT reader (evidence: `src/LowFiFxPlugin.cpp`)
- Packed LUT Reader → Cube LUT Parser: converts LUTs (evidence: `src/LutPack.h`)
- OFX Effect → Preset Reader: references presets (evidence: `src/LowFiFxPlugin.cpp`)
- OFX Effect → Metal Renderer: dispatches rendering (evidence: `src/LowFiFxPlugin.cpp`)
- OFX Effect → CUDA Interface: selects backend (evidence: `src/LowFiFxPlugin.cpp`)
- CUDA Interface → CUDA Stubs: implemented by (evidence: `src/CudaKernels.cpp`)
- Metal Renderer → Render Parameters: consumes parameters (evidence: `src/MetalKernels.h`)
- CUDA Interface → Render Parameters: consumes parameters (evidence: `src/CudaKernels.h`)
- Metal Renderer → Metal Kernel Source: uses kernels
- OFX Effect → DaVinci Resolve: returns processed image
- Colour LUT Assets → Packed LUT Reader: packed at build time
