Skip to content

Commit d49411d

Browse files
rupsishollasch
authored andcommitted
Listing 28: Adding in scatter method signature change for all materials
1 parent 5017c95 commit d49411d

File tree

1 file changed

+51
-3
lines changed

1 file changed

+51
-3
lines changed

books/RayTracingTheRestOfYourLife.html

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2349,6 +2349,57 @@
23492349

23502350
...
23512351
};
2352+
2353+
class metal : public material {
2354+
public:
2355+
...
2356+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
2357+
bool scatter(
2358+
const ray& r_in, const hit_record& rec, color& attenuation, ray& scattered, double& pdf
2359+
) const override {
2360+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
2361+
...
2362+
}
2363+
};
2364+
2365+
class dielectric : public material {
2366+
public:
2367+
...
2368+
2369+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
2370+
bool scatter(
2371+
const ray& r_in, const hit_record& rec, color& attenuation, ray& scattered, double& pdf
2372+
) const override {
2373+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
2374+
...
2375+
}
2376+
};
2377+
2378+
class diffuse_light : public material {
2379+
public:
2380+
...
2381+
2382+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
2383+
bool scatter(
2384+
const ray& r_in, const hit_record& rec, color& attenuation, ray& scattered, double& pdf
2385+
) const override {
2386+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
2387+
...
2388+
}
2389+
};
2390+
2391+
class isotropic : public material {
2392+
public:
2393+
...
2394+
2395+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
2396+
bool scatter(
2397+
const ray& r_in, const hit_record& rec, color& attenuation, ray& scattered, double& pdf
2398+
) const override {
2399+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
2400+
...
2401+
}
2402+
};
23522403
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
23532404
[Listing [scatter-onb]: <kbd>[material.h]</kbd> Scatter function, with orthonormal basis]
23542405

@@ -2373,12 +2424,9 @@
23732424
isotropic(const color& albedo) : tex(make_shared<solid_color>(albedo)) {}
23742425
isotropic(shared_ptr<texture> tex) : tex(tex) {}
23752426

2376-
2377-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
23782427
bool scatter(
23792428
const ray& r_in, const hit_record& rec, color& attenuation, ray& scattered, double& pdf
23802429
) const override {
2381-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
23822430
attenuation = tex->value(rec.u, rec.v, rec.p);
23832431
scattered = ray(rec.p, random_unit_vector(), r_in.time());
23842432
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight

0 commit comments

Comments
 (0)