Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

class lambertian should have constructors for color or texture #516

Closed
hollasch opened this issue May 6, 2020 · 0 comments
Closed

class lambertian should have constructors for color or texture #516

hollasch opened this issue May 6, 2020 · 0 comments

Comments

@hollasch
Copy link
Collaborator

hollasch commented May 6, 2020

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.

@hollasch hollasch added this to the v3.2.0 milestone May 6, 2020
@hollasch hollasch self-assigned this May 17, 2020
hollasch added a commit that referenced this issue May 17, 2020
Add alternative constructors that take color arguments in addition to
the constructors that take shared_ptr<texture> arguments, simplifying
calling code. This applies to the following clases:

  - checker_texture
  - constant_medium
  - diffuse_light
  - lambertian

Resolves #516
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

1 participant