Rust port of RTIOW by Peter Shirley, v3.1.2, 2020-06-03
https://raytracing.github.io/
Completed books are tagged as a release.
- - Ray Tracing in One Weekend
- - The Next Week
- - The Rest of Your Life
I believe I've stayed close to the spirit of the book while still writing Rust.
Multi-threading was trivially added with rayon
for the last render of the
first book. All renders after that were multi-threaded.
A primitive command line interface exists, scenes and threading need to be adjusted by recompiling. Each flag is optional. Default values are 100 samples and 384 pixel width, height will be calculated with an aspect ratio of 16:9 if not specified. Arbitrary aspect ratios are supported.
cargo run --release -- [filename.ppm] [samples] [width] [height] [seed]
All images were done with 100 samples and 50 bounces.
Creating a blue to white background gradient
Placing the first sphere in the scene
Showing the normals of the sphere's surface
Adding a ground plane with another large sphere
Multiple samples per pixel, anti-aliasing
The first diffuse material
Gamma correcting the linear light
Improving the scattering calculation
The first Lambert material
Adding metallic materials
First pass of dielectric materials, light is only reflected
Added the chance for refraction to occur
Placed another sphere inside the dielectric to make a glass bubble effect
Added a Snell's law correction
Added camera controls to adjust the field of view
Adjusting FOV for zooming out
Zooming in with another FOV adjustment
Depth of field blur is added
Final scene as on the cover of the book, with some personal touches added
All images are 100 samples unless otherwise noted. With BVH and multi-threading, sample count can be increased dramatically and still finish in a very tolerable time.
I was better about saving the scenes in this, grouping the camera with it. However, due to the nature of the book, enough incremental churn occurs that it's not convenient to keep every camera, world, and rendering combination pictured here.
I made an enum for the Perlin noise to allow for selection from any of the types made over the course of the chapter: trilinear, unfiltered, net/camouflage, smooth, and marble (with turbulence).
Chapter 2: Bouncing Spheres, simulating motion blur
Chapter 4: Added a checker texture to the ground,
implemented bounding volume hierarchies for massive render speedup in some
scenes - 400 samples
Two checker spheres
Chapter 5: Hashed Perlin noise
Playing with the previous scene, added motion blur to one sphere
5.2: Perlin noise with trilinear interpolation.
5.3: Trilinear filtering with cubic Hermite
5.4: High frequency scaling for the noise, this is a scale of 20
The book example seems to be a frequency of 4, determined through trial and
error
5.5 Perlin noise with random unit vectors on lattice points
5.6 Substituting turbulence in for the noise function, not the intended
result as in the book
Multiplying turbulence directly by the color as illustrated in the book
5.7 Adjusting the phase of turbulence, making a marble texture
Chapter 6: Using images as textures
Chapter 7: Turning objects into lights, small rectangle light
Adding a sphere to the scene - 1,000 samples
Empty Cornell box. Aspect ratio changed to 1:1. My result doesn't appear
to have flipped normals like in the book - 1,000 samples
Added flipped face material for less noise with axis-aligned planes - 1,000
samples
Cornell box, now with blocks but not rotated - 1,000 samples
Standard Cornell box scene with rotated boxes - 1,000 samples
Cornell with blocks of smoke - 1,000 samples
Final scene, 400 samples. The scene's Perlin noise is not reproducible from
the instructions given in the book, there are some artifacts due to lack of
samples but render times are very long. I spent a few hours trying to figure out
why my result didn't look like the book. We do have nice volumetric fog and
caustics in the glass material though.
See: RayTracing/raytracing.github.io#425
This book focuses on different sampling methods and comparisons of the Cornell box scene, so I've skipped their inclusion. Topics covered included Monte Carlo integration and using probability density functions to sample the lights and hittables in the scene directly.
Sampling the lights directly, finished in under a second - 10 samples
Made the light one-sided, removed some noise near the light - 10 samples
Added mixture PDF for mixing the contributions of lighting and reflection -
1,000 samples
Added specular to the model, metal block in the Cornell scene - 1,000 samples
Sphere with new PDF functions - 1,000 samples