Skip to content

Commit ebeab16

Browse files
committed
Add next tasks
1 parent 02b6575 commit ebeab16

2 files changed

Lines changed: 250 additions & 0 deletions

File tree

docs/tasks/render-mode.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Render Mode
2+
3+
Generate high-quality images (and eventually videos) from scene definitions.
4+
5+
## Relevant Files
6+
7+
- `crates/host/src/cli.rs` - CLI definitions (will add `render` subcommand)
8+
- `crates/host/src/gpu.rs` - `render_to_image()` for offscreen rendering
9+
- `renders/*.toml` - Render definition files (proposed)
10+
- `renders/` - Output directory for rendered images
11+
12+
## Overview
13+
14+
Run `cargo run --release -- render [name]` to generate an image. Without a name, renders all definitions in `renders/`. Output saved to `renders/<name>.png`.
15+
16+
## Status
17+
18+
- [ ] Basic render subcommand
19+
- [ ] TOML definition parsing
20+
- [ ] Single image output
21+
- [ ] Pass quality settings to shader
22+
23+
### Future Enhancements
24+
25+
- [ ] Video output (frame sequence or encoded video)
26+
- [ ] Camera animation via spline paths (reuse `CameraPath` from benchmarking)
27+
- [ ] Progress indicator for long renders
28+
29+
## Render Definition Format
30+
31+
Render definitions live in `renders/<name>.toml`:
32+
33+
```toml
34+
scene = "cornell_box_fs"
35+
36+
[camera]
37+
position = [278.0, 278.0, -800.0]
38+
look_at = [278.0, 278.0, 0.0]
39+
40+
[quality]
41+
samples = 100 # rays per pixel (px_samples)
42+
bounces = 50 # max ray bounces (max_ray_bounce)
43+
44+
[output]
45+
width = 1920
46+
height = 1080
47+
```
48+
49+
### Comparison with Benchmark Format
50+
51+
Benchmarks and renders share similar structure. A unified format could support both use cases:
52+
53+
```toml
54+
scene = "cornell_box_fs"
55+
56+
[camera]
57+
# Static camera (render) - just position + look_at
58+
position = [278.0, 278.0, -800.0]
59+
look_at = [278.0, 278.0, 0.0]
60+
61+
# OR animated camera (benchmark/video) - spline paths
62+
# position = [[...], [...], ...]
63+
# look_at = [[...], [...], ...]
64+
# duration = 10.0
65+
66+
[quality]
67+
samples = 100
68+
bounces = 50
69+
70+
[output]
71+
width = 1920
72+
height = 1080
73+
74+
# Optional: what to produce
75+
# mode = "image" # single frame render
76+
# mode = "benchmark" # timing data, no image saved
77+
# mode = "video" # frame sequence (future)
78+
```
79+
80+
The key difference: benchmarks use animated camera paths and record timing; renders use static cameras (or animated for video) and save images. Could potentially merge into one format where:
81+
- Static camera + image mode = render
82+
- Animated camera + benchmark mode = benchmark
83+
- Animated camera + video mode = video render
84+
85+
## Open Questions
86+
87+
- Should render definitions live in `renders/` or a separate `scenes/` directory?
88+
- Should output go to `renders/` or `output/` or `renders/output/`?
89+
- Unified format vs separate formats for benchmark/render?

docs/tasks/scene-definitions.md

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
# Scene Definitions
2+
3+
Define scenes in TOML files instead of hardcoded shaders.
4+
5+
## Relevant Files
6+
7+
- `crates/shader/src/scene.rs` - Current hardcoded scene functions
8+
- `crates/rtx-obj/src/lib.rs` - `Sphere`, `Quad`, `List` primitives
9+
- `crates/rtx-mat/src/lib.rs` - `Lambertian`, `Metal`, `Dielectric`, `DiffuseLight` materials
10+
- `crates/rtx-tex/src/lib.rs` - `SolidTexture` and texture table
11+
12+
## Overview
13+
14+
Currently scenes are hardcoded as shader entry points (`cornell_box_fs`, `two_spheres_fs`, etc.). Each scene function builds primitives, materials, and textures at shader runtime. This works but:
15+
- Adding a scene requires recompiling the shader
16+
- Scene parameters can't be tweaked without code changes
17+
- Benchmarks and renders must reference shader entry point names
18+
19+
Scene TOML files would allow defining scenes declaratively. The host parses the TOML and uploads scene data to the GPU via buffers, replacing the hardcoded scene functions with a single generic renderer.
20+
21+
## Status
22+
23+
- [ ] Design TOML schema for scenes
24+
- [ ] GPU buffer layout for scene data
25+
- [ ] Host-side TOML parsing and buffer upload
26+
- [ ] Generic shader entry point that reads from buffers
27+
- [ ] Migrate existing scenes to TOML format
28+
29+
### Future Enhancements
30+
31+
- [ ] Live reload: watch TOML files and re-upload on change
32+
- [ ] Scene includes: reference other TOML files for reusable object groups
33+
- [ ] Procedural generation: loops/randomization in scene definition
34+
35+
## Scene Definition Format
36+
37+
Scenes live in `scenes/<name>.toml`:
38+
39+
```toml
40+
[camera]
41+
# Default camera for this scene (can be overridden by render/benchmark)
42+
position = [278.0, 278.0, -800.0]
43+
look_at = [278.0, 278.0, 0.0]
44+
vfov = 40.0
45+
focus_dist = 10.0
46+
defocus_angle = 0.0
47+
48+
[[materials]]
49+
name = "white"
50+
type = "lambertian"
51+
color = [0.73, 0.73, 0.73]
52+
53+
[[materials]]
54+
name = "red"
55+
type = "lambertian"
56+
color = [0.65, 0.05, 0.05]
57+
58+
[[materials]]
59+
name = "light"
60+
type = "diffuse_light"
61+
color = [15.0, 15.0, 15.0]
62+
63+
[[materials]]
64+
name = "glass"
65+
type = "dielectric"
66+
refraction_index = 1.5
67+
68+
[[materials]]
69+
name = "mirror"
70+
type = "metal"
71+
color = [0.8, 0.8, 0.8]
72+
fuzz = 0.0
73+
74+
[[objects]]
75+
type = "quad"
76+
corner = [555.0, 0.0, 0.0]
77+
u = [0.0, 555.0, 0.0]
78+
v = [0.0, 0.0, 555.0]
79+
material = "white"
80+
81+
[[objects]]
82+
type = "sphere"
83+
center = [190.0, 90.0, 190.0]
84+
radius = 90.0
85+
material = "glass"
86+
```
87+
88+
### Material Types
89+
90+
| Type | Fields |
91+
|------|--------|
92+
| `lambertian` | `color` |
93+
| `metal` | `color`, `fuzz` (0.0-1.0) |
94+
| `dielectric` | `refraction_index` |
95+
| `diffuse_light` | `color` (can exceed 1.0 for brightness) |
96+
97+
### Object Types
98+
99+
| Type | Fields |
100+
|------|--------|
101+
| `sphere` | `center`, `radius`, `material` |
102+
| `quad` | `corner`, `u`, `v`, `material` |
103+
104+
## Integration with Renders and Benchmarks
105+
106+
Render and benchmark TOMLs would reference scenes by name or define inline:
107+
108+
**Reference by name:**
109+
```toml
110+
scene = "cornell_box" # loads scenes/cornell_box.toml
111+
112+
[camera]
113+
position = [278.0, 278.0, -800.0]
114+
look_at = [278.0, 278.0, 0.0]
115+
116+
[quality]
117+
samples = 100
118+
bounces = 50
119+
```
120+
121+
**Inline scene definition:**
122+
```toml
123+
[camera]
124+
position = [13.0, 2.0, 3.0]
125+
look_at = [0.0, 0.0, 0.0]
126+
127+
[quality]
128+
samples = 50
129+
bounces = 10
130+
131+
[scene]
132+
[[scene.materials]]
133+
name = "ground"
134+
type = "lambertian"
135+
color = [0.5, 0.5, 0.5]
136+
137+
[[scene.objects]]
138+
type = "sphere"
139+
center = [0.0, -1000.0, 0.0]
140+
radius = 1000.0
141+
material = "ground"
142+
```
143+
144+
## GPU Buffer Design
145+
146+
Scene data must be uploaded to the GPU since TOML is parsed on the host. Rough layout:
147+
148+
- **Material buffer**: array of material structs (kind + parameters)
149+
- **Object buffer**: array of object structs (kind + geometry + material index)
150+
- **Texture buffer**: (future) image data for texture mapping
151+
152+
The shader would have a single entry point that reads these buffers instead of calling scene-specific functions. This requires:
153+
1. Defining fixed-size buffer layouts (max objects, max materials)
154+
2. Or using storage buffers with dynamic sizing (if rust-gpu supports)
155+
156+
## Open Questions
157+
158+
- Max object/material counts? Fixed compile-time limits vs dynamic?
159+
- How to handle the `List<NS, NQ>` const generics with dynamic scene sizes?
160+
- Should hardcoded scenes remain as fallbacks or be fully replaced?
161+
- Texture support: inline color only, or path to image files?

0 commit comments

Comments
 (0)