Skip to content
/ rtiow Public

Rust port of the Raytracing in One Weekend series, with pictures

Notifications You must be signed in to change notification settings

okaneco/rtiow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rtiow - Ray Tracing in One Weekend

book0 cover

book1 cover

pdf for sphere

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

Table of Contents

  1. Ray Tracing in One Weekend
  2. The Next Week
  3. The Rest of Your Life

Notes

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.

Ray Tracing in One Weekend

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
blue blend
Placing the first sphere in the scene
red sphere
Showing the normals of the sphere's surface
sphere normals
Adding a ground plane with another large sphere
normal sphere ground
Multiple samples per pixel, anti-aliasing
multi sample
The first diffuse material
diffuse
Gamma correcting the linear light
diffuse gamma correct
Improving the scattering calculation
diffuse random unit vector
The first Lambert material
materials lambert
Adding metallic materials
metals
First pass of dielectric materials, light is only reflected
all refract
Added the chance for refraction to occur
sometimes refract
Placed another sphere inside the dielectric to make a glass bubble effect
bubble
Added a Snell's law correction
snell
Added camera controls to adjust the field of view
wide view
Adjusting FOV for zooming out
distant view
Zooming in with another FOV adjustment
zoom view
Depth of field blur is added
dof
Final scene as on the cover of the book, with some personal touches added
final scene

Back to top

The Next Week

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
bouncing spheres
Chapter 4: Added a checker texture to the ground, implemented bounding volume hierarchies for massive render speedup in some scenes - 400 samples
checkerboard floor
Two checker spheres
checkered spheres
Chapter 5: Hashed Perlin noise
perlin noise squares
Playing with the previous scene, added motion blur to one sphere
perlin square with motion blur
5.2: Perlin noise with trilinear interpolation.
perlin noise with trilinear filter
5.3: Trilinear filtering with cubic Hermite
perlin trilinear filter smoothed
5.4: High frequency scaling for the noise, this is a scale of 20
perlin noise with higher frequency
The book example seems to be a frequency of 4, determined through trial and error
perlin with frequency to match book
5.5 Perlin noise with random unit vectors on lattice points
perlin with random unit vectors
5.6 Substituting turbulence in for the noise function, not the intended result as in the book
perlin with turbluence
Multiplying turbulence directly by the color as illustrated in the book
perlin with turbluence direct
5.7 Adjusting the phase of turbulence, making a marble texture
perlin turbulent marble texture
Chapter 6: Using images as textures
earth on a sphere
Chapter 7: Turning objects into lights, small rectangle light
rectangle light
Adding a sphere to the scene - 1,000 samples
sphere light
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
sphere light
Added flipped face material for less noise with axis-aligned planes - 1,000 samples
sphere light
Cornell box, now with blocks but not rotated - 1,000 samples
sphere light
Standard Cornell box scene with rotated boxes - 1,000 samples
cornell box scene
Cornell with blocks of smoke - 1,000 samples
cornell smoke scene
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
testing everything

Back to top

The Rest of Your Life

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
sample lights directly
Made the light one-sided, removed some noise near the light - 10 samples
unidirectional light
Added mixture PDF for mixing the contributions of lighting and reflection - 1,000 samples
mixture
Added specular to the model, metal block in the Cornell scene - 1,000 samples
specular metal box
Sphere with new PDF functions - 1,000 samples
pdf for sphere

Back to top

About

Rust port of the Raytracing in One Weekend series, with pictures

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages