-
Notifications
You must be signed in to change notification settings - Fork 59
Home
Rust crate to implement at least parts of the PBRT book's C++ code:
Current Rust documentation:
https://www.janwalter.org/doc/rust/pbrt/index.html
The library is kept in a single file (called src/lib.rs), an example directory contains several example files using the library.
Warning: Currently you need to download and compile with Rust nightly:
rustup install nightly
rustup default nightly
cargo test --release
One executable does use the library and generates a test scene purely with API calls:
./target/release/examples/pbrt_spheres_differentials_texfilt -h
Usage: ./target/release/examples/pbrt_spheres_differentials_texfilt [options]
Options:
-h, --help print this help menu
-c, --checker use procedural texture
-i, --image use image texture
-n, --none use no texture
-m, --matte use only matte materials
-v, --version print version number
The second executable can parse a scene description via the pest crate:
./target/release/examples/pest_test -h
Usage: ./target/release/examples/pest_test [options]
Options:
-h, --help print this help menu
-i FILE parse an input file
-v, --version print version number
You can render the same test scene as above (using a texture file on the ground) like this:
./target/release/examples/pest_test -i assets/scenes/spheres-differentials-texfilt.pbrt
The scene can be rendered by simply pointing to another provided input file:
./target/release/examples/pest_test -i assets/scenes/teapot-area-light.pbrt
The resulting image is almost identical to the C++ version of PBRT:
The scene will be used for global illumination, but here is how it looks like with direct lighting:
./target/release/examples/pest_test -i assets/scenes/cornell_box.pbrt
Integrator "directlighting" "integer maxdepth" [10]
The resulting image matches the C++ counterpart a hundred percent:
imf_diff -d -f pbrt.png pbrt_cpp.png
pbrt.png pbrt_cpp.png: no differences.
== "pbrt.png" and "pbrt_cpp.png" are identical
To render the same scene with path tracing you have to use another integrator:
Integrator "path"
For the following picture I also increased the settings integer pixelsamples and used the Gaussian pixel filter:
diff --git a/assets/scenes/cornell_box.pbrt b/assets/scenes/cornell_box.pbrt
index 9ec3516..fe25b0e 100644
--- a/assets/scenes/cornell_box.pbrt
+++ b/assets/scenes/cornell_box.pbrt
@@ -10,7 +10,7 @@ Film "image"
"integer yresolution" [ 500 ]
## "integer outlierrejection_k" [ 10 ]
##Sampler "sobol"
-Sampler "lowdiscrepancy" "integer pixelsamples" [8]
+Sampler "lowdiscrepancy" "integer pixelsamples" [512]
##PixelFilter "blackmanharris"
##SurfaceIntegrator "bidirectional"
##Integrator "directlighting" "integer maxdepth" [10]
Without releasing another version there was a task to implement ambient occlusion (AO), and here is the resulting image:
You have to change the following line to use the AOIntegrator
:
Integrator "ambientocclusion"
The forth provided scene can be parsed but does not render (yet):
> ./target/release/examples/pest_test -i assets/scenes/example.pbrt
...
do something with created tokens ...
...
TODO: UVMapping2D
...
TODO: CreateDiskShape
...
WorldEnd
done.
The scene comes from here: