summaryrefslogtreecommitdiff
path: root/doc/ARCHITECTURE.md
diff options
context:
space:
mode:
Diffstat (limited to 'doc/ARCHITECTURE.md')
-rw-r--r--doc/ARCHITECTURE.md26
1 files changed, 26 insertions, 0 deletions
diff --git a/doc/ARCHITECTURE.md b/doc/ARCHITECTURE.md
index 4c36ec5..ebb2a59 100644
--- a/doc/ARCHITECTURE.md
+++ b/doc/ARCHITECTURE.md
@@ -4,6 +4,28 @@ Detailed system architecture for the 64k demo project.
---
+## SDF Camera System
+
+**Purpose**: Unified camera infrastructure for SDF raymarching effects.
+
+**CameraParams** (80 bytes, `src/gpu/camera_params.h`):
+- `inv_view`: mat4 (inverse view matrix for screen→world transform)
+- `fov`, `near_plane`, `far_plane`, `aspect_ratio`: f32 (camera parameters)
+
+**SDFEffect Base Class** (`src/gpu/sdf_effect.h`):
+- Manages `UniformBuffer<CameraParams>`
+- Provides `update_camera()` helper methods (from Camera object or manual values)
+- Standard binding: 0=CommonUniforms, 1=CameraParams
+
+**WGSL Helpers** (`common/shaders/camera_common.wgsl`):
+- `getCameraRay(cam, uv)`: Generate ray from screen UV coordinates
+- `getCameraPosition/Forward/Up/Right()`: Extract camera vectors from inv_view
+- Integrates with existing `render/raymarching.wgsl` (rayMarch, normal, shadow)
+
+**Usage**: Effects inherit from SDFEffect, update camera each frame, shader accesses camera uniforms for raymarching.
+
+---
+
## Hybrid 3D Renderer
**Core Idea**: Uses standard rasterization to draw proxy hulls (boxes), then raymarches inside the fragment shader to find the exact SDF surface.
@@ -18,6 +40,10 @@ Detailed system architecture for the 64k demo project.
**Effect**: Abstract base for visual elements. Supports `compute` and `render` phases.
+**PostProcessEffect**: Subclass for full-screen post-processing effects.
+
+**SDFEffect**: Subclass for SDF raymarching effects with camera management (see SDF Camera System below).
+
**Sequence**: Timeline of effects with start/end times defined in beats.
**MainSequence**: Top-level coordinator and framebuffer manager.