Project page with paper pdf and supplemental video can be found here.
Note that this is all research-quality code. The interesting bits are contained entirely within /src/compute.wgsl
.
- Download and install Rust
- Clone this repository
- Run
cargo run --release -- --Awarnings
in the root directory
- Press
r
to hot-reload/src/compute.wgsl
- Camera controls are
w
,a
,s
,d
+ mouse to look - Scroll up or down to change movement speed
- If the camera controls feel wrong, disable the scene-dependant view matrix modifications in
fn rt_main
in/src/compute.wgsl
Ctrl+f
for "PARAMETERS" in/src/compute.wgsl
, here you will find the following:localsubdiv
controls the octree resolution, e.g., 8 -> (2^8, or 256)^3 and 10 -> (2^10, or 1024)^3delta
controls the temporal error tolerance, e.g., 0.01 (depends on the Lipschitz bounds off
)pointsample
enables world-space point-sampling within indeterminate leavesfastenabled
enables the fast-evaluation optimizationlipschitz_corrected
enables Lipschitz-correction on deltaswept_volume
enables swept-volume renderingnormalvis
sets the surface color to the world-space normalscinematic
enables naive pathtracing withtotalsamples
samples per pixelfast_normals
enables per-pixel normals via finite-differencescene
selects which scene's normals (iffast_normals
is true) / lighting / camera settings to use
- To enable fullscreen, set
shouldbefullscreen
in/src/main.rs
to true - To save frames to disk, set
save_frames_to_disk
in/src/main.rs
to true - To save timing data to disk, set
save_timing_to_disk
in/src/main.rs
to true
- Make
file_contents
in/src/IR.rs
read fromscenes/something_else.ll
- Set
scene
in/src/compute.wgsl
according to the comment next to it
- Create new file
/scenes/example.cpp
and paste in your GLSL code - The field function must be named
f
, mapping 4 floatsx,y,z,t
to a single float - Paste this at the top of
/scenes/example.cpp
#include <math.h> #include <cstring> #include "include/swizzle/setup.h" #include "overloads.h"
- Install Clang and run
./compile.sh example
to generateexample.ll
- Fiddle with the code until
example.ll
contains no branches or casts in the field function - In
/src/IR.rs
point the constructor's file contents toscenes/example.ll
- Set
scene
in/src/compute.wgsl
to some new value - Make sure
fast_normals
in/src/compute.wgsl
is set to false to get per-voxel normals. If you want per-pixel normals, keep reading
-
Paste your GLSL code into a temp file called
example.frag
-
Paste this at the top of
example.frag
layout(location = 0) out vec4 color; void main() { color = vec4(0.0); }
-
Run
naga example.frag example.wgsl
in the CLI -
Paste the contents of
example.wgsl
at the top of/src/compute.wgsl
, ignoring theFragmentOutput
andcolor
lines (top of the file) as well asfn main()
(bottom of file) -
Rename
fn f
to something else, e.g.,fn example
-
Add a new case to
fn finite_diff_normal
in/src/compute.wgsl
to callfn example
ifscene
is set appropriately -
Make sure
scene
in/src/compute.wgsl
is set to your new value -
Set
fastenabled
in/src/compute.wgsl
to true so thatfn finite_diff_normals
is used
I've tested this code on Windows 10, Vulkan backend, with an RTX 3080 / i7 3930k. It should in theory work on other operating systems / GPUs and even the web thanks to wgpu. If you need help setting it up, please open an issue.