File size: 2,660 Bytes
ac9d706
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
license: mit
tags:
  - neural-rendering
  - ray-tracing
  - radiance-cache
  - graphics
library_name: pytorch
---

# Neural Ray Tracing — Radiance Cache

The light-transport analog of the
[neural physics engine](https://huggingface.co/NeuralVerified/neural-physics-engine)
thesis: keep visibility and direct lighting **analytic**, learn **only the
indirect transport** with a tiny tied MLP. One analytic ray + next-event
estimation + a network lookup replaces the many-bounce random walk after
the first hit.

## How it was done

Render decomposition: `L = emitted + direct(analytic) + indirect(learned)`.

1. **Ground truth**: a small PyTorch path tracer
   (`engine3d/raytrace.py`) renders high-spp references and splits each
   pixel into emitted / direct / indirect components.
2. **Training data**: first-hit surface points + normals paired with the
   path-traced indirect radiance at those points.
3. **The cache** (`engine3d/neural_rt.py`): one tiny MLP shared across the
   whole scene (the tied-embedding structure used everywhere in this
   project) maps (hit point, normal) → indirect RGB.
4. **Composition**: at render time, trace one analytic primary ray, add
   analytic direct lighting (NEE), and look up the cache for the rest.
5. **Evaluation** (`experiments/w9_neural_radiance_cache.py`): PSNR on a
   held-out camera view, compared against an *equal-cost* few-spp path
   trace, plus the spp the baseline needs to match the neural render.

`experiments/w11_world_lighting.py` applies the same recipe to bake a
world ambient/GI field (`world_light.pt`) over the voxel world — this is
the "neural GI" used live in the
[Neural World demo Space](https://huggingface.co/spaces/NeuralVerified/neural-world),
parsed in-browser by `pt_loader.js`.

## Checkpoints

| file | net | consumed by |
|---|---|---|
| `experiments/radiance_cache.pt` | indirect radiance cache MLP | `w9_neural_radiance_cache.py` renders |
| `experiments/world_light.pt` | world ambient/GI field | Neural World demo (browser) |

## Validation

![neural raytrace validation](neural_raytrace_validation.png)
![world lighting validation](world_lighting_validation.png)

## Reproduce

```
python experiments/w9_neural_radiance_cache.py   # trains + renders comparison
python experiments/w11_world_lighting.py         # bakes world_light.pt
```


---

<!-- neuralverified-relocation-note -->
> **Now hosted by [NeuralVerified](https://huggingface.co/NeuralVerified).**
>
> This repo was moved into the NeuralVerified organization to help organize my profile.
> Originally published at [`Quazim0t0/neural-raytracing`](https://huggingface.co/Quazim0t0/neural-raytracing).