Release Notes for v0.5.2

Documentation

I provide documentation for the latest official release and intermediate (between releases) updates. The main difference is that one links to source code (for example to the TranslucentMaterial struct), whereas the other does not, but is updated more frequently.

Re-writing the Parser

The biggest change for this release is a total re-write of the pest based parser. The driving force was issue #41, which is only about the Include statements. The new parser works in kind of two phases. The first phase reads the input file line by line, skips entire comment lines (lines starting with an #) and empty lines, but combines several lines into a single string for statements. Those combined statement lines are parsed separately in the second phase.

But the main advantage of the new parser is that it can call itself recursively e.g. for Include lines and parse each file separately while using API calls to store the read information in a scene description.

Here an example scene which contains only 36 lines, but includes another file with 1.5 million curves:

Stanford Bunny with fur

WindyTexture

I already posted about the Cover image for the first edition, but I didn't explain that I had to implement a WindyTexture for the waves on the creek, which in turn uses fractional Brownian motion (fBm).

TranslucentMaterial

In the next scene a texture was used for bump mapping on the water surface:

Barcelona Pavilion - Day

Barcelona Pavilion - Night

The leaves on the background trees needed a new TranslucentMaterial (see issue 89):

> rg translucent
geometry.pbrt
144:                        "string type" [ "translucent" ] 
176:                        "string type" [ "translucent" ] 
208:                        "string type" [ "translucent" ] 
307:                            "string type" [ "translucent" ] 
341:                            "string type" [ "translucent" ]

A more efficient GraphicsState

The C++ code was updated after the book's publication to implemented a copy on write approach for a more efficient GraphicsState management. I asked on the Rust forum what the Rust equivalent for those maps would be. I got several useful hints, which I might use in the future, but I ended up with simply wrapping the used HashMap with Arc, which means that pushing the GraphicsState would simply increase the reference counter, until a new HashMap entry actually gets added. E.g. like this:

Arc::make_mut(&mut api_state.graphics_state.float_textures).insert(...);

Minor changes

There was an issues #88, which created NaNs while rendering the ecosys.pbrt test scene. This was fixed by using i32 instead of usize in noise_flt() and grad().

With the Barcelona Pavilion scene I ran into a problem with a matte material, which was basically fixed by this commit.

The End

I hope I didn't forget anything important. Have fun and enjoy the v0.5.2 release.