Skip to content

moddyz/RayTracingTheNextWeek

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RayTracingTheNextWeek

An implementation of the book Ray Tracing: The Next Week.

Table of Contents

Dependencies

The following dependencies are mandatory:

  • C++ compiler
  • CMake (3.12 or greater)

Building

Example snippet for building this project:

mkdir build && cd build
cmake -DCMAKE_INSTALL_PREFIX="/apps/CXXTemplate/" ..
cmake --build  . -- VERBOSE=1 -j8 all install

Prequel

The implementation to the prequel at RayTracingInOneWeekend.

Programs

0. Motion Blur

Image

Simulate the effect of motion blur, by introducing the concept of time to rays and scene objects.

Rays are fired at random times between shutter open and close to produce the averaged image across that time interval.

Scene objects now possess attributes. Attributes store values for multiple time samples, and supports queries between, or beyond available samples. For more information, see the class documentation for Attribute.

Source code

Link to Chapter 2

1. Bounding Volume Hierarchies

Image

Introducing bounding volume hierarchy (BVH) to accelerate the ray tracing. The BVH reduces the number of intersection tests performed per-ray by pruning out hierarchies of scene objects whose bounding volume does not intersect with the ray.

With the same scene from 0. Motion Blur:

  • With BVH: 10.575s
  • Without BVH: 216.854s

Measurements taken using the time Linux command line utility, on a Thinkpad X1 Extreme outfitted with Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz.

Source code

Link to Chapter 3

2. Solid Textures

Image

Introducing textures to sample colors from. Textures are available as a type of material parameter, such as the "albedo" parameter for Lambert.

In the image above, the ground plane is assigned a Lambert material with a CheckerTexture for its albedo parameter.

Source code

Link to Chapter 4

3. Perlin Noise

Image

Introduced a Perlin noise generator, for producing smooth noise.

By accumulating multiple layers of perlin noise applied to a sine function over the Z-coordinate, a marble-like texture is generated.

Source code

Link to Chapter 5

4. Image Texture Mapping

Image

Introduced image based textures, which can be loaded from a file on disk.

During color sampling, the geometric surface coordinates (uv) are mapped to a particular image pixel coordinate.

Source code

Link to Chapter 6

5. Rectangles and Lights

Image

Introducing emissive materials to provide local lighting to the scene, and a new Box scene object class.

Source code

Link to Chapter 7

6. Volumes

Image

Adding a ConstantMedium for a volume of particulates.

The ConstantMedium is associated with a geometric shape, and models ray hitting particles via a probability based on distance that the ray travels through the volume.

Any particle hit will cause the ray to be scattered in a random direction thanks to the new Isotropic material.

Source code

Link to Chapter 9

7. A Scene Testing All New Features

Image

The final render, testing all the new features learned in Ray Tracing: The Next Week.

Rendered with 15,000 samples per pixel.

Source code

Link to Chapter 10

Sequel

The implementation of the sequel is available under RayTracingTheRestOfYourLife.

Releases

No releases published

Packages

No packages published