T3 Reflection (Milestone 1)

T3.1 Calculating the reflection vector in vec3.h

We have introduced how to calculate the reflection vector when introducing the Phong model. The difference here is that we are calculating the reflection vector of the viewing direction.

Add a function reflect in vec3.h outside the vec3 class

T3.2 Add a metal material in material.h

Similar to the lambertian material, it inherits from class material and needs to implement its own scatter() method.

The difference is that it is using the reflected direction instead of a random direction to calculate secondary rays.

T3.3 Modify Camera's ray_color() method for our changes

Add a material.h in the header section of camera.h

Modify the ray_color() method of class camera in camera.h

Build Your Scene of Spheres in main.cpp

Add material.h before sphere.h.

Adding spheres to your world as suggested.

Build and Run Your Program

If building is successful, run your program in the terminal as follows using your executable name

You are going to see a lovely photo like the following

You can hardly achieve that mirror reflection with raster graphics.

T3.4 Fuzz reflection (glossy)

Fuzzy reflection is a reflection which is not fullly mirror reflective, it is also calleed glossy. To achieve that we can add noise to the reflection vector.

Add a fuzz parameter to the metal material (material.h)

Add fuzz parameters in main()

If successful, you are going to see the following output

Last updated