Ray Tracing 010: Metal


Metal

Continuing with materials, this chapter will introduce a generic materials class and two first material child classes for diffuse (Lambertian) and reflective/metallic materials.

@TODO: add write-up

Updated Files

hittable.h

  • added material class and mat_ptr

main.cpp

  • added material.h
  • addd random.h
  • replaced drand48() with random_double()
  • moved random_in_unit_sphere() to material.h
  • added depth parameter to color() function
  • in color(), update to use new material with depth of 50 calls, moved previous target for diffuse material to 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 the link to the Javascript implementation:

Please see my repository at github.com/celeph/ray-tracing for the complete code. For more details, check out Peter Shirley’s excellent book that inspired this episode: “Ray Tracing in One Weekend” and his original book and code repo.

Credits and Further Reading

Next Steps