-
Notifications
You must be signed in to change notification settings - Fork 945
Closed
Description
In the second book, the lambertian
material is converted from taking a color
in the constructor to a texture
, changing this:
lambertian(const color& a) : albedo(a) {}
to this
lambertian(shared_ptr<texture> a) : albedo(a) {}
In the process, the reader is told to go back over their code and update all lambertian
values to now use the new solid_color
texture where they used to have color, so
...make_shared<lambertian>(color(0.5, 0.5, 0.5))
should get updated to
...make_shared<lambertian>(make_shared<solid_color>(0.5, 0.5, 0.5))
Seems like it would be easier to have two lambertian
constructors, like so:
lambertian(const color& a) : albedo(make_shared<solid_color>(a)) {}
lambertian(shared_ptr<texture> a) : albedo(a) {}
The result is that the lambertian can take either color or texture, and the reader doesn't have to go back to update everything.