Free as in Freedom: Codeberg.org. Create your repos and join us!
Join Donate
Home
Jan Walter edited this page 7 months ago

Rust crate to implement at least parts of the PBRT book’s C++ code:

http://www.pbrt.org

Current Rust documentation:

https://www.janwalter.org/doc/rust/pbrt/index.html

Current Status

The library is kept in several files and sub-folders (in the src directory), an example directory contains several example files using the library.

API

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

Checker

Use procedural texture

Image

Use image texture

No Texture

use no texture

Matte

Only matte materials

Parser

The second executable can parse a scene description via the pest crate:

./target/release/examples/rs_pbrt -h
Usage: ./target/release/examples/rs_pbrt [options]

Options:
    -h, --help          print this help menu
    -i FILE             parse an input file
    -t, --nthreads NUM  use specified number of threads for rendering
    -v, --version       print version number

Spheres

You can render the same test scene as above (using a texture file on the ground) like this:

./target/release/examples/rs_pbrt -i assets/scenes/spheres-differentials-texfilt.pbrt

Teapot

The scene can be rendered by simply pointing to another provided input file:

./target/release/examples/rs_pbrt -i assets/scenes/teapot-area-light.pbrt

The resulting image is almost identical to the C++ version of PBRT:

Teapot scene rendered via Rust version of PBRT

Cornell Box

The scene will be used for global illumination, but here is how it looks like with direct lighting:

./target/release/examples/rs_pbrt -i assets/scenes/cornell_box.pbrt
Integrator "directlighting" "integer maxdepth" [10]

The resulting image matches the C++ counterpart a hundred percent:

Cornell Box scene rendered via Rust version of
 PBRT

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:

Cornell Box scene rendered via Rust version of PBRT using path
 tracing (low
 settings)

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:

Cornell Box scene rendered via Rust using
 AO

You have to change the following line to use the AOIntegrator:

Integrator "ambientocclusion"

Simple room

> ./target/release/examples/rs_pbrt -i assets/scenes/simple_room.pbrt

Simple room rendered via Rust using path
 tracing

This scene is also available for various other renderers:

https://github.com/wahn/export_multi/tree/master/01_simple_room

Cafe scene

> ./target/release/examples/rs_pbrt -i assets/scenes/cafe_scene1.pbrt

Cafe scene rendered via Rust using path
 tracing

or

> ./target/release/examples/rs_pbrt -i assets/scenes/cafe_scene2.pbrt

Variation of the cafe scene rendered via Rust using path
 tracing

This scene is also available for various other renderers:

https://github.com/wahn/export_multi/tree/master/02_cafe_scene

Art Gallery

The scene is quiet big, you have to gunzip it first (via ‘gunzip art_gallery.pbrt.gz’).

> ./target/release/examples/rs_pbrt -i assets/scenes/art_gallery.pbrt

Art gallery rendered via Rust using direct
lighting

This scene was rendered using direct lighting (no global illumination) and is also available for various other renderers:

https://github.com/wahn/export_multi/tree/master/03_art_gallery

Conference Room

The scene is quiet big, you have to gunzip it first (via ‘gunzip conference_room.pbrt.gz’).

> ./target/release/examples/rs_pbrt -i assets/scenes/conference_room.pbrt

Conference Room rendered via Rust using path
tracing

This scene is also available for various other renderers:

https://github.com/wahn/export_multi/tree/master/04_conference_room

There is blog post showing different camera perspectives of the same scene.

Example .pbrt File

> ./target/release/examples/rs_pbrt -i assets/scenes/example.pbrt

Example of a pbrt file from
pbrt.org

The scene comes from here:

http://www.pbrt.org/fileformat-v3.html#example