First picture rendered via Rust version of PBRT

08 May 2017

Release Notes

v0.1.0

First picture rendered via Rust version of PBRT:

First
picture rendered via Rust version of PBRT.

The original scene, rendered by the C++ version of PBRT, can be seen here:

Original scene
rendered by the C++ version of PBRT.

Version 0.1.0 keeps the library in a single file with 7173 lines of code:

> wc lib.rs 
  7173  31925 268293 lib.rs

The first 613 lines are mainly used to create parts of the documentation and example code mentioned there. More examples are kept in a subdirectory (called examples) and the one file used to render the image above is called pbrt_spheres_differentials_texfilt.rs. Version 0.1.0 consists of 51 public structs, 5 enums, 5 traits, and 61 public functions:

> grep "^pub struct" lib.rs | wc
     51     204    1302
> grep "^pub enum" lib.rs | wc
      5      20     115
> grep "^pub trait" lib.rs | wc
      5      20     108
> grep "^pub fn" lib.rs | wc
     61     500    3549

As you can see in the scene file below, the original scene consists of a distant light, two spheres and a triangle mesh. Beside fixing the problem with the poles of the spheres, where the image renders black, version 0.1.0 does not deal with the mirror nor the glass material yet, but uses a matte material for all shapes. It also can not handle textures (like the checker pattern on the floor).

LookAt 2 2 5   0 -.4 0 0 1 0
Camera "perspective" "float fov" [30 ]

Film "image" "integer xresolution" [1000 ] "integer yresolution" [500 ] 
    "string filename" "spheres-differentials-texfilt.exr"

Integrator "directlighting" "integer maxdepth" [10]

Sampler "lowdiscrepancy" "integer pixelsamples" [1]
PixelFilter "box"

WorldBegin
LightSource "distant" "point from" [0 10 0 ] "point to" [0 0 0 ]
    "color L" [3.141593 3.141593 3.141593 ] 

AttributeBegin
	Translate .25 0 0
	Texture "checker" "color" "checkerboard" 
		"string mapping" "planar"
		"vector v1" [ 1 0 0 ] "vector v2" [ 0 0 1]
		"string aamode" ["none"]
Texture "lines-tex" "color" "imagemap" "string filename" "textures/lines.png"
	"float uscale" [100] "float vscale" [100]

	Material "matte" "texture Kd" "lines-tex"
    Shape "trianglemesh"  "integer indices" [0 2 1 0 3 2 ] 
	"point P" [-100 -1 -100 400 -1 -100 400 -1 400 -100 -1 400 ] 
        "float st" [ 0 0 1 0 0 1 1 1]
AttributeEnd

Translate -1.3 0 0 
Material "mirror"
Shape "sphere"

Translate 2.6 0 0 
Material "glass"
Shape "sphere"
WorldEnd

There is no parser to read the scene file. All lights, shapes, and materials are hardcoded into the example file (pbrt_spheres_differentials_texfilt.rs) by using Rust’s structs from the library implementation:

extern crate pbrt;
...
use pbrt::{..., Scene, ..., Sphere, ..., Triangle, TriangleMesh, ...};
use std::string::String;
use std::sync::Arc;
...
fn main() {
...
    builder.add_mesh(object_to_world,
                     world_to_object,
                     n_triangles,
                     vertex_indices,
                     n_vertices,
                     p_ws, // in world space
                     s, // empty
                     n, // empty
                     uv);

    // sphere
...
    builder.add_sphere(object_to_world,
                       world_to_object,
                       radius,
                       z_min,
                       z_max,
                       phi_max);

    // sphere
...
    builder.add_sphere(object_to_world,
                       world_to_object,
                       radius,
                       z_min,
                       z_max,
                       phi_max);
...
    let scene: Scene = Scene::new(accelerator.clone(), render_options.lights);
    integrator.render(&scene);
}

Finally, version 0.1.0 is not mutli-threaded yet.

v0.1.1

An improved picture rendered via Rust version of PBRT:

Improved
picture rendered via Rust version of PBRT.

Basically the black spots on the ground of the test scene are gone now.

v0.1.2

The correct picture for matte materials rendered via the Rust version of PBRT:

Correct
picture rendered for matte materials via the Rust version of PBRT.

We are ready to implement the mirror material now.

v0.1.3

Scene with a mirror material on the second sphere, rendered via the Rust version of PBRT:

Scene with
a mirror material on the second sphere, rendered for matte materials
via the Rust version of PBRT.

We are ready to implement the glass material now.

v0.1.4

Scene with a glass material on the first sphere and a mirror material on the second sphere, rendered via the Rust version of PBRT:

Scene with
a glass material on the first sphere and a mirror material on the
second sphere, rendered for matte materials via the Rust version of
PBRT.

We are ready to implement the texture handling on the ground mesh now.

v0.1.5

Scene with a glass material on the first sphere and a mirror material on the second sphere. The ground triangles use a procedural checker texture on a matte material. Rendered via the Rust version of PBRT:

Scene with
glass, mirror, and matte materials using a procedural texture.

v0.1.6

Scene with a glass material on the first sphere and a mirror material on the second sphere. The ground triangles use a texture on a matte material. Rendered via the Rust version of PBRT:

Scene with
glass, mirror, and matte materials using a non-procedural texture.

For comparison, the original scene, rendered by the C++ version of PBRT:

Original scene
rendered by the C++ version of PBRT.

We can start to implement multi-threading now, before the scenes get more complex and the rendering times go up. This simple scene should still render (without multi-threading) within a few seconds.

v0.1.7

Version 0.1.7 renders the same image as v0.1.6 using all available CPUs. See Release Notes