enginerenderer 0.0.1

A zero-dependency offline rendering engine in pure Rust — CPU path tracing, BVH acceleration, 16-band spectral rendering, PBR materials, animation & video export.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
<div align="center">

# 🎥 EngineRenderer 🎥

### A zero-dependency offline rendering engine in pure Rust

<br>

`CPU Path Tracing` · `BVH Acceleration` · `16-Band Spectral Rendering` · `PBR Materials` · `Animation & Video`

<br>

[![Rust](https://img.shields.io/badge/Rust-edition_2024-f74c00?style=for-the-badge&logo=rust&logoColor=white)](#-building)
[![Platforms](https://img.shields.io/badge/Linux_·_macOS_·_Windows_·_Android-0078d4?style=for-the-badge&logo=linux&logoColor=white)](#-cross-platform-support)
[![Build Matrix](https://img.shields.io/badge/All_listed_architectures-compiling-success?style=for-the-badge&logo=rust&logoColor=white&color=2ea44f)](#-cross-platform-support)
[![Crates](https://img.shields.io/badge/external_crates-0-2ea44f?style=for-the-badge)](#-stats)
[![License](https://img.shields.io/badge/MIT-license-yellow?style=for-the-badge)](License)

<br>

**478 source files** · **~49,060 lines** · **17 material presets** · **18 interpolation curves** · **9+ targets**

</div>

<br>

## 🎨 Features

<table>
<tr><td>

### Rendering Pipeline

| | |
|:--|:--|
| 🔦 **Path Tracing** | Configurable SPP (1–64+), multi-bounce, BVH-accelerated |
| 🌈 **Spectral** | 16-band wavelength dispatch, CIE 1931 XYZ conversion |
| 🪩 **PBR Materials** | Albedo · roughness · metallic · emission · IOR · subsurface · anisotropy · iridescence · clearcoat · transmission |
| 🎭 **17 Presets** | Stellar · planetary · manufactured · celestial · natural |
| 💡 **Lighting** | Area lights · soft shadows · cascaded shadow maps (PCF + contact) |
| 🌫️ **Volumetrics** | God rays · participating media · atmospheric scattering · clouds |
|**Post-Processing** | Bloom · blur · depth-of-field (physical lens) · tone mapping |
| 🏎️ **Motion Blur** | Time-sampled primitives |
| 🎯 **Optimization** | Adaptive sampling · firefly rejection · denoising · frustum culling · LOD |

</td></tr>
</table>

### Render Presets

```
AnimationFast ·········  1 SPP · 1 bounce · denoised previews
PreviewCpu ············  4 SPP · 1 bounce · adaptive sampling
UltraHdCpu ············ 16 SPP · 3 bounces · high-quality stills
ProductionReference ··· 64 SPP · max bounces · reference quality
```

### Realtime 120 FPS Profile

EngineRenderer includes a unified ultra-constrained realtime profile for `--fps 120`.

- Scene-side budget: proxy showcase geometry, reduced light budget, optional panorama removal
- Runtime-side budget: cached showcase meshes, static realtime scene reuse, BVH reuse
- Loop-side budget: deadline-based frame pacing with drift compensation
- Runtime adaptation: smoothed quality bias, sample pressure, scheduler granularity, and hysteresis-based internal resolution scaling

Validated runtime benchmarks (release, 3 seconds, `--fps 120 --width 1280 --height 720`):

- Linux x86_64: stable high-frequency cadence with adaptive runtime controls
- Android ARM64: constrained-device adaptation validated with dynamic internal resolution and scheduler tuning

### 🎬 Animation

| | |
|:--|:--|
| ⏱️ Timeline keyframes | Camera · sun · sky · exposure |
| 📐 18 interpolations | Linear · Step · SmoothStep · Hermite · EaseIn/Out/InOut (Quad, Cubic, Sine, Expo) · Back · Bounce |
| 🎞️ Frame sequencer | Batch rendering with caching |
| 📹 Video export | MP4 via system FFmpeg |

### 🏗️ Scene Building

| | |
|:--|:--|
| 🔗 Fluent API | `SceneBuilder` · `MaterialBuilder` · `CameraController` |
| 📄 Scene format | Text-based `.scene` files with serialization & parsing |
| 📦 Mesh import | OBJ · glTF/GLB |
| 🔧 Procedural | Geometry generators · mesh operations · composite objects |

### ⚛️ Physics & Simulation

| | |
|:--|:--|
| 💥 Rigid bodies | Constraint solving · collision detection · raycasting |
| 🪐 N-body | Gravitational simulation for celestial mechanics |

### 🤖 AI Integration

| | |
|:--|:--|
| 🔍 Introspection | `Capabilities::discover()` → JSON feature description |
| 💬 Prompt-to-scene | Natural language → renderable scene |
| 📷 Camera presets | Front · top-down · dramatic · cinematic · closeup |

### 🧩 Runtime Subsystems

| | |
|:--|:--|
| 🧠 Scripting VM | Stack-based bytecode VM with `Push` · `Add/Sub/Mul/Div` · `Jmp/JmpIf` · `Eq/Ne/Lt/Gt/Le/Ge` · `Call/Ret` · `Load/Store` · `Neg/Not` · `CallNative` |
| 📜 Script runner | `ScriptRunner` compiles expressions and dispatches to the VM with native function registration |
| 🔁 Hot reload | `HotReloader` watches script files and triggers `ScriptRunner::load_from_file` on change |
| 🧬 ECS | Sparse-set `TypedStorage<T>` · `ComponentRegistry` · entity spawn/remove with type-erased component storage |

<br>

## 🏛️ Architecture

```
╔══════════════════════════════════════════════════════════════════╗
║                          API Layer                              ║
║   SceneBuilder · MaterialCatalog · CameraController             ║
║   AnimationClip · Timeline · FrameSequencer                     ║
║   AiRenderer · Capabilities · SceneDescriptor                   ║
╠══════════════════════════════════════════════════════════════════╣
║                         Core Engine                             ║
║   Path Tracer · BVH · Spectral Shading · Shadow Maps            ║
║   Volumetrics · Post-Processing · Scene Graph · Physics         ║
║   Animation Sequencer · Video Exporter · Scheduler              ║
║   ECS (TypedStorage) · Scripting VM · Hot Reload                ║
╠══════════════════════════════════════════════════════════════════╣
║                  Hardware Abstraction Layer                      ║
║   CPU (topology, SIMD) · GPU (DRM/D3D12) · Display · DMA       ║
╚══════════════════════════════════════════════════════════════════╝
```

📋 Full module breakdown: [arborescence.md](arborescence.md)

<br>

## 🌍 Cross-Platform Support

<table>
<tr>
<td width="50%">

### Targets

| Target | Arch | OS |
|:-------|:-----|:---|
| `x86_64-unknown-linux-gnu` | x86_64 | Linux |
| `i686-unknown-linux-gnu` | x86 | Linux |
| `aarch64-unknown-linux-gnu` | ARM64 | Linux |
| `armv7-unknown-linux-gnueabihf` | ARMv7 | Linux |
| `x86_64-apple-darwin` | x86_64 | macOS Intel |
| `aarch64-apple-darwin` | ARM64 | macOS Silicon |
| `x86_64-pc-windows-gnu` | x86_64 | Windows |
| `i686-pc-windows-gnu` | x86 | Windows |
| `aarch64-linux-android` | ARM64 | Android |

> + musl variants for static linking

✅ All listed targets compile successfully.

✅ `cargo clippy --target x86_64-pc-windows-gnu` passes cleanly.

</td>
<td width="50%">

### SIMD Detection

| ISA | Extensions |
|:----|:-----------|
| x86 / x86_64 | SSE4.2 · AVX · AVX-512 |
| ARM / AArch64 | NEON · SVE |
| *Fallback* | Scalar paths |

### GPU Drivers

| OS | Drivers |
|:---|:--------|
| Linux | `amdgpu` `radeon` `i915` `xe` `nouveau` `mali` `msm` |
| Windows | D3D12 / DXGI |
| macOS | AppleGPU · Intel iGPU |

> Automatic CPU fallback if no GPU available

</td>
</tr>
</table>

<br>

## 🔨 Building

| Dependency | Required | Notes |
|:-----------|:--------:|:------|
| **Rust** || Edition 2024 |
| **FFmpeg** || Only for MP4 export |

```bash
cargo build --release
```

Quick start: [quickstart.md](quickstart.md)

<details>
<summary>🔀 <strong>Cross-compilation targets</strong></summary>

```bash
cargo build --release --target aarch64-apple-darwin         # Apple Silicon
cargo build --release --target aarch64-unknown-linux-gnu    # ARM64 Linux
cargo build --release --target x86_64-pc-windows-gnu        # Windows (MinGW)
cargo build --release --target aarch64-linux-android         # Android
cargo build --release --target x86_64-unknown-linux-musl    # Static Linux
```

</details>

<br>

## 🚀 Usage

### CLI Mode

```bash
cargo run --release -- render    # Standard render → output file
cargo run --release -- gallery   # Full gallery showcase
cargo run --release -- test      # Quick smoke test
cargo run --release -- detect    # Hardware/compute diagnostics
cargo run --release -- gpu-render # GPU pipeline render
cargo run --release -- video     # Render animation → MP4
cargo run --release -- run       # Realtime preview mode
cargo run --release -- help      # Show commands
```

#### Detect / Debug options

```bash
cargo run --release -- detect --verbose
cargo run --release -- detect --json --component gpu
cargo run --release -- detect --bench --component cpu
cargo run --release -- detect --override arch=arm,os=windows,vendor=amd
```

Supported values:

- `--component`: `cpu`, `gpu`, `ram`, `display`, `all`
- `--override`: `arch=x86|arm`, `os=linux|windows|macos`, `vendor=amd|intel|apple|unknown`

### Interactive Terminal

Launch with **no arguments** for a full REPL with module navigation and built-in docs:

```bash
cargo run --release
```

```
╭───────── Root Namespace ─────────╮
│ 🚀Welcome in Helper🚀           │
│                                  │
│ 📦 Modules:                     │
│   🧠 ai         🎬 animation   │
│   📷 camera     ⚙ engine       │
│   🎨 materials  📦 objects     │
│   🌌 scenes     🧩 types       │
╰──────────────────────────────────╯
```

<details>
<summary>📖 <strong>All REPL commands</strong></summary>
<br>

| Command | Description |
|:--------|:------------|
| `open <module>` | Enter a module namespace |
| `call <fn>` | Execute a function |
| `inspect <item>` | Show details |
| `docs [target] [section]` | Browse source documentation |
| `animate [topic]` | Show execution flow |
| `back` | Return to root |
| `clear` | Clear screen |
| `exit` | Quit |

**engine** → `call render` · `call gallery` · `call test` · `call run`

**animation** → `call spheres` · `call cubes` · `call house` · `call city` · `call car` · `call world` · `call blackhole`

</details>

<details>
<summary>📚 <strong>Built-in documentation browser</strong></summary>
<br>

The REPL reads source code directly:

```
engine> docs                        # List all topics
engine> docs readme                 # README
engine> docs tree                   # Project structure
engine> docs changelog              # Changelog
engine> docs rendering              # Rendering pipeline
engine> docs ai.renderer            # Sub-module docs
engine> docs ai.prompt constraints  # Section filter
```

Sections: `overview` · `constraints` · `implementation` · `tips`

</details>

<br>

### Render Examples

Standalone GPU example binaries live in `examples/`:

```bash
cargo run --release --example gpu_render_demo   # GPU pipeline showcase
cargo run --release --example gpu_render_heavy  # Heavy GPU workload stress
cargo run --release --example gpu_window        # Windowed GPU preview
```

CPU gallery scenes (spheres, cubes, house, city, car, world, blackhole) are exposed via the gallery command and the REPL:

```bash
cargo run --release -- gallery              # Render the full CPU gallery
```

```
engine> open animation
animation> call spheres        # or cubes · house · city · car · world · blackhole
```

### 🌀 Rendu vidéo / Animation

Le mode `video` génère une animation MP4 à partir d'une scène :

```bash
cargo run --release -- video --duration=10 --fps=30 --width=1920 --height=1080 --output-mp4=output/animation.mp4
```

Chargement d'une scène existante :

```bash
cargo run --release -- video --scene-file=my_scene.scene --output-mp4=output/animation.mp4
```

| Option | Défaut | Description |
|:-------|:------:|:------------|
| `--duration=N` | `5` | Durée en secondes |
| `--fps=N` | `30` | Images par seconde |
| `--width=N` | `1280` | Largeur en pixels |
| `--height=N` | `720` | Hauteur en pixels |
| `--quality=preview\|hd\|production` | `preview` | Qualité de rendu |
| `--scene-file=PATH` | *(défaut)* | Scène `.scene` à charger |
| `--output-dir=PATH` | `output/video` | Dossier frames temporaires |
| `--output-mp4=PATH` | `output/video/animation.mp4` | Fichier MP4 final |
| `--prefix=NAME` | `frame` | Préfixe des frames |

<br>

## ✅ Validation Suite

The workspace includes rendering validation tests under `tests/workspace_render_validation.rs`:

- Visual determinism regression for preview outputs
- Parallel stress rendering over multiple workers
- Long-run pacing campaign (ignored by default)
- Diagnostics benchmark matrix campaign (ignored by default)

Run the standard suite:

```bash
cargo test
```

Run the dedicated workspace validation file:

```bash
cargo test --test workspace_render_validation
```

Run ignored long campaigns explicitly:

```bash
cargo test --test workspace_render_validation -- --ignored
```

Core quality gates used in this workspace:

```bash
cargo check --all-targets
cargo clippy --all-targets
```

Latest status (see [ChangeLog.md](ChangeLog.md) `0.0.1`):

- `cargo clippy` clean on `x86_64-unknown-linux-gnu` (0 warnings)
- Scripting VM dispatch covers `CallNative` end-to-end (encode → decode → execute → native dispatch → `VmError::UnknownNative` reporting via `Display`)
- ECS `TypedStorage::component_count` exposed via both inherent and trait surfaces
- Hot-reload runtime log reports `watched_paths()` and per-script `is_loaded(...)`

<br>

### 📦 Library API

```rust
use enginerenderer::api::engine::Engine;
use enginerenderer::api::scenes::builder::SceneBuilder;
use enginerenderer::api::materials::catalog::MaterialCatalog;
use enginerenderer::api::objects::primitives::RenderPreset;
use enginerenderer::api::animation::{AnimationClip, Timeline, Interpolation, FrameSequencer};
```

<details>
<summary><strong>Code examples</strong></summary>
<br>

**Default render:**
```rust
let report = Engine::default().run()?;
println!("Rendered {}x{} in {} ms", report.width, report.height, report.duration_ms);
```

**Production gallery:**
```rust
let reports = Engine::production_reference().render_gallery()?;
for report in reports {
    println!("{}", report.output_path.display());
}
```

**Smoke test:**
```rust
let report = Engine::test_minimal().run()?;
```

**AI capabilities:**
```rust
let caps = enginerenderer::api::ai::capabilities::Capabilities::discover();
```

**Hardware diagnostics:**
```rust
enginerenderer::api::diagnose_compute_environment();
```

</details>

<br>

## 📁 Output Formats

| Format | Extension | Notes |
|:------:|:---------:|:------|
| PPM | `.ppm` | Default still image |
| EXR | `.exr` | HDR framebuffer |
| PNG | `.png` | Compressed stills |
| MP4 | `.mp4` | Video (FFmpeg) |

<br>

## 📊 Stats

<div align="center">

| Source files | Lines of Rust | External crates | Material presets | Interpolation curves | Render presets | Targets | Edition |
|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|
| **478** | **~49,060** | **0** | **17** | **18** | **4** | **9+** | **2024** |

</div>

<br>

<div align="center">

## License

[MIT](License)

</div>