Peter Shirely's Ray Tracing in One Weekend presents the following function to calculate the color of a lambertian material (See chapter's 7 and 8):
bool lambertian::scatter(ray ray_in, hit_record rec, vec3& attenuation, ray &scattered) {
vec3 target = rec.p + rec.normal + random_in_unit_sphere();
scattered = ray(rec.p, target - rec.p);
attenuation = this->albedo;
return true;
}
I've read through other material that mentions Lambert's Cosine Law when discussing diffuse materials. Why is the cos
term omitted from Peter Shirely's text? Is it canceled out somehow? My expectation is that the attenuation term should look something like:
attenuation = this->albedo * dot(rec.normal, ray_in.direction);