Ray Tracing 010Metal

Summary

  • Added a generic material class.
  • Added two child classes for diffuse (Lambertian) and reflective/metallic materials.

Here's a quick overview of the changes made to support reflective and metallic materials:

hittable.h

  • added material class and mat_ptr

main.cpp

  • added material.h
  • added random.h
  • replaced drand48() with random_double()
  • moved random_in_unit_sphere() to material.h
  • added depth parameter to color() function
  • in color(), updated to use new material with depth of 50 calls, moved previous target for diffuse materials to its dedicated class
  • replaced MAXFLOAT with INFINITY
  • in main(), added depth parameter to color(), added material to spheres, added two spheres to list

sphere.h

  • added material pointer

material.h

  • new file with base material class and two child classes for diffuse and reflective materials

Here's also my Javascript rendering:

Loading...

Links