Skip to content

Commit b0a1293

Browse files
committed
Merge remote-tracking branch 'origin/explain-sphere-uv' into explain-sphere-uv
2 parents f9e2c1c + 9b7aa22 commit b0a1293

File tree

7 files changed

+107
-123
lines changed

7 files changed

+107
-123
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,20 @@ Change Log -- Ray Tracing in One Weekend
55

66
### Common
77
- Change: refactor `sphere::hit()` method to reuse common blocks of code.
8-
- Fix: Added `fmin` to book text for `cos_theta` of `refract`
8+
- Fix: Added `fmin` to book text for `cos_theta` of `refract` (#732)
99
- Fix: Standardized naming for ray-t and time parameters (#746)
10+
- Fix: `random_unit_vector()` was incorrect (#697)
1011

1112
### In One Weekend
1213

1314
### The Next Week
1415
- Add: Improved explanation of `get_sphere_uv()` function (#533)
1516

1617
### The Rest of Your Life
18+
- Fix: Missing `override` keyword for `xz_rect::pdf_value()` and `xz_rect::random()` methods
19+
(#748)
20+
- Fix: Synchronize book and source for `cornell_box()` function.
21+
- Fix: Introduction of light code was introduced out of sequence (#738, #740)
1722
- Add: Improved explanation of `get_sphere_uv()` function (#533)
1823

1924

books/RayTracingInOneWeekend.html

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1738,16 +1738,18 @@
17381738

17391739
However, we are interested in a Lambertian distribution, which has a distribution of $\cos (\phi)$.
17401740
True Lambertian has the probability higher for ray scattering close to the normal, but the
1741-
distribution is more uniform. This is achieved by picking points on the surface of the unit sphere,
1742-
offset along the surface normal. Picking points on the sphere can be achieved by picking points in
1743-
the unit ball, and then normalizing those.
1741+
distribution is more uniform. This is achieved by picking random points on the surface of the unit
1742+
sphere, offset along the surface normal. Picking random points on the unit sphere can be achieved by
1743+
picking random points _in_ the unit sphere, and then normalizing those.
17441744

17451745
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
1746+
inline vec3 random_in_unit_sphere() {
1747+
...
1748+
}
1749+
1750+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
17461751
vec3 random_unit_vector() {
1747-
auto a = random_double(0, 2*pi);
1748-
auto z = random_double(-1, 1);
1749-
auto r = sqrt(1 - z*z);
1750-
return vec3(r*cos(a), r*sin(a), z);
1752+
return unit_vector(random_in_unit_sphere());
17511753
}
17521754
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17531755
[Listing [random-unit-vector]: <kbd>[vec3.h]</kbd> The random_unit_vector() function]

books/RayTracingTheRestOfYourLife.html

Lines changed: 72 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -544,33 +544,12 @@
544544

545545
$$ \int cos^2(\theta) $$
546546

547-
<div class='together'>
548547
By MC integration, we should just be able to sample $\cos^2(\theta) / p(\text{direction})$, but what
549-
is direction in that context? We could make it based on polar coordinates, so $p$ would be in terms
550-
of $(\theta, \phi)$. However you do it, remember that a PDF has to integrate to 1 and represent the
551-
relative probability of that direction being sampled. We have a method from the last books to take
552-
uniform random samples in or on a unit sphere:
553-
554-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
555-
vec3 random_unit_vector() {
556-
auto a = random_double(0, 2*pi);
557-
auto z = random_double(-1, 1);
558-
auto r = sqrt(1 - z*z);
559-
return vec3(r*cos(a), r*sin(a), z);
560-
}
561-
562-
...
563-
564-
vec3 random_in_unit_sphere() {
565-
while (true) {
566-
auto p = vec3::random(-1,1);
567-
if (p.length_squared() >= 1) continue;
568-
return p;
569-
}
570-
}
571-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
572-
[Listing [random-unit-vector]: <kbd>[vec3.h]</kbd> Random vector of unit length]
573-
</div>
548+
is _direction_ in that context? We could make it based on polar coordinates, so $p$ would be in
549+
terms of $(\theta, \phi)$. However you do it, remember that a PDF has to integrate to 1 and
550+
represent the relative probability of that direction being sampled. Recall that we have vec3
551+
functions to take uniform random samples in (`random_in_unit_sphere()`) or on
552+
(`random_unit_vector()`) a unit sphere.
574553

575554
<div class='together'>
576555
Now what is the PDF of these uniform points? As a density on the unit sphere, it is $1/\text{area}$
@@ -757,35 +736,36 @@
757736

758737
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
759738
...
760-
color ray_color(
739+
color ray_color(...) {
761740
...
741+
}
762742

763743
hittable_list cornell_box() {
764-
hittable_list world;
744+
hittable_list objects;
765745

766746
auto red = make_shared<lambertian>(color(.65, .05, .05));
767747
auto white = make_shared<lambertian>(color(.73, .73, .73));
768748
auto green = make_shared<lambertian>(color(.12, .45, .15));
769749
auto light = make_shared<diffuse_light>(color(15, 15, 15));
770750

771-
world.add(make_shared<yz_rect>(0, 555, 0, 555, 555, green));
772-
world.add(make_shared<yz_rect>(0, 555, 0, 555, 0, red));
773-
world.add(make_shared<xz_rect>(213, 343, 227, 332, 554, light));
774-
world.add(make_shared<xz_rect>(0, 555, 0, 555, 555, white));
775-
world.add(make_shared<xz_rect>(0, 555, 0, 555, 0, white));
776-
world.add(make_shared<xy_rect>(0, 555, 0, 555, 555, white));
751+
objects.add(make_shared<yz_rect>(0, 555, 0, 555, 555, green));
752+
objects.add(make_shared<yz_rect>(0, 555, 0, 555, 0, red));
753+
objects.add(make_shared<xz_rect>(213, 343, 227, 332, 554, light));
754+
objects.add(make_shared<xz_rect>(0, 555, 0, 555, 555, white));
755+
objects.add(make_shared<xz_rect>(0, 555, 0, 555, 0, white));
756+
objects.add(make_shared<xy_rect>(0, 555, 0, 555, 555, white));
777757

778758
shared_ptr<hittable> box1 = make_shared<box>(point3(0,0,0), point3(165,330,165), white);
779759
box1 = make_shared<rotate_y>(box1, 15);
780760
box1 = make_shared<translate>(box1, vec3(265,0,295));
781-
world.add(box1);
761+
objects.add(box1);
782762

783763
shared_ptr<hittable> box2 = make_shared<box>(point3(0,0,0), point3(165,165,165), white);
784764
box2 = make_shared<rotate_y>(box2, -18);
785765
box2 = make_shared<translate>(box2, vec3(130,0,65));
786-
world.add(box2);
766+
objects.add(box2);
787767

788-
return world;
768+
return objects;
789769
}
790770

791771
int main() {
@@ -799,10 +779,6 @@
799779

800780
// World
801781

802-
auto lights = make_shared<hittable_list>();
803-
lights->add(make_shared<xz_rect>(213, 343, 227, 332, 554, shared_ptr<material>()));
804-
lights->add(make_shared<sphere>(point3(190, 90, 190), 90, shared_ptr<material>()));
805-
806782
auto world = cornell_box();
807783

808784
color background(0,0,0);
@@ -1524,21 +1500,21 @@
15241500

15251501
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
15261502
hittable_list cornell_box() {
1527-
hittable_list world;
1503+
hittable_list objects;
15281504

15291505
auto red = make_shared<lambertian>(color(.65, .05, .05));
15301506
auto white = make_shared<lambertian>(color(.73, .73, .73));
15311507
auto green = make_shared<lambertian>(color(.12, .45, .15));
15321508
auto light = make_shared<diffuse_light>(color(15, 15, 15));
15331509

1534-
world.add(make_shared<yz_rect>(0, 555, 0, 555, 555, green));
1535-
world.add(make_shared<yz_rect>(0, 555, 0, 555, 0, red));
1510+
objects.add(make_shared<yz_rect>(0, 555, 0, 555, 555, green));
1511+
objects.add(make_shared<yz_rect>(0, 555, 0, 555, 0, red));
15361512
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
1537-
world.add(make_shared<flip_face>(make_shared<xz_rect>(213, 343, 227, 332, 554, light)));
1513+
objects.add(make_shared<flip_face>(make_shared<xz_rect>(213, 343, 227, 332, 554, light)));
15381514
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
1539-
world.add(make_shared<xz_rect>(0, 555, 0, 555, 555, white));
1540-
world.add(make_shared<xz_rect>(0, 555, 0, 555, 0, white));
1541-
world.add(make_shared<xy_rect>(0, 555, 0, 555, 555, white));
1515+
objects.add(make_shared<xz_rect>(0, 555, 0, 555, 555, white));
1516+
objects.add(make_shared<xz_rect>(0, 555, 0, 555, 0, white));
1517+
objects.add(make_shared<xy_rect>(0, 555, 0, 555, 555, white));
15421518

15431519
...
15441520
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -1690,8 +1666,7 @@
16901666

16911667
return emitted
16921668
+ albedo * rec.mat_ptr->scattering_pdf(r, rec, scattered)
1693-
* ray_color(scattered, background, world, depth-1)
1694-
/ pdf_val;
1669+
* ray_color(scattered, background, world, depth-1) / pdf_val;
16951670
}
16961671
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
16971672
[Listing [ray-color-cos-pdf]: <kbd>[main.cc]</kbd> The ray_color function, using cosine pdf]
@@ -1821,8 +1796,7 @@
18211796

18221797
return emitted
18231798
+ albedo * rec.mat_ptr->scattering_pdf(r, rec, scattered)
1824-
* ray_color(scattered, background, world, depth-1)
1825-
/ pdf_val;
1799+
* ray_color(scattered, background, world, depth-1) / pdf_val;
18261800
}
18271801
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
18281802
[Listing [ray-color-hittable-pdf]: <kbd>[main.cc]</kbd> ray_color function with hittable PDF]
@@ -1872,15 +1846,8 @@
18721846
<div class='together'>
18731847
And plugging it into `ray_color()`:
18741848

1875-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
1876-
color ray_color(
1877-
const ray& r,
1878-
const color& background,
1879-
const hittable& world,
1880-
shared_ptr<hittable> lights,
1881-
int depth
1882-
) {
18831849
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
1850+
color ray_color(const ray& r, const color& background, const hittable& world, int depth) {
18841851
hit_record rec;
18851852

18861853
// If we've exceeded the ray bounce limit, no more light is gathered.
@@ -1912,8 +1879,7 @@
19121879

19131880
return emitted
19141881
+ albedo * rec.mat_ptr->scattering_pdf(r, rec, scattered)
1915-
* ray_color(scattered, background, world, lights, depth-1)
1916-
/ pdf_val;
1882+
* ray_color(scattered, background, world, depth-1) / pdf_val;
19171883
}
19181884
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19191885
[Listing [ray-color-mixture]: <kbd>[main.cc]</kbd> The ray_color function, using mixture PDF]
@@ -1972,7 +1938,7 @@
19721938

19731939

19741940

1975-
Cleaning Up PDF Management.
1941+
Cleaning Up PDF Management
19761942
====================================================================================================
19771943

19781944
<div class='together'>
@@ -2077,14 +2043,15 @@
20772043
<div class='together'>
20782044
And `ray_color()` changes are small:
20792045

2080-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
2046+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
20812047
color ray_color(
20822048
const ray& r,
20832049
const color& background,
20842050
const hittable& world,
20852051
shared_ptr<hittable> lights,
20862052
int depth
20872053
) {
2054+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
20882055
hit_record rec;
20892056

20902057
// If we've exceeded the ray bounce limit, no more light is gathered.
@@ -2109,10 +2076,32 @@
21092076

21102077
return emitted
21112078
+ srec.attenuation * rec.mat_ptr->scattering_pdf(r, rec, scattered)
2112-
* ray_color(scattered, background, world, lights, depth-1)
2113-
/ pdf_val;
2079+
* ray_color(scattered, background, world, lights, depth-1) / pdf_val;
21142080
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
21152081
}
2082+
2083+
...
2084+
2085+
int main() {
2086+
...
2087+
// World
2088+
2089+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
2090+
auto lights = make_shared<hittable_list>();
2091+
lights->add(make_shared<xz_rect>(213, 343, 227, 332, 554, shared_ptr<material>()));
2092+
lights->add(make_shared<sphere>(point3(190, 90, 190), 90, shared_ptr<material>()));
2093+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
2094+
2095+
auto world = cornell_box();
2096+
2097+
color background(0,0,0);
2098+
2099+
for (int j = image_height-1; j >= 0; --j) {
2100+
std::cerr << "\rScanlines remaining: " << j << ' ' << std::flush;
2101+
for (int i = 0; i < image_width; ++i) {
2102+
...
2103+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
2104+
pixel_color += ray_color(r, background, world, lights, max_depth);
21162105
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
21172106
[Listing [ray-color-scatter]: <kbd>[main.cc]</kbd> Ray color with scatter]
21182107
</div>
@@ -2218,32 +2207,31 @@
22182207

22192208
return emitted + srec.attenuation
22202209
* rec.mat_ptr->scattering_pdf(r, rec, scattered)
2221-
* ray_color(scattered, background, world, lights, depth-1)
2222-
/ pdf_val;
2210+
* ray_color(scattered, background, world, lights, depth-1) / pdf_val;
22232211
}
22242212
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22252213
[Listing [ray-color-implicit]: <kbd>[main.cc]</kbd>
22262214
Ray color function with implicitly-sampled rays]
22272215
</div>
22282216

22292217
<div class='together'>
2230-
We also need to change the block to metal.
2218+
We also need to change the block to metal. We'll also swap out the short block for a glass sphere.
22312219

22322220
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
2233-
hittable_list cornell_box(camera& cam, double aspect) {
2234-
hittable_list world;
2221+
hittable_list cornell_box() {
2222+
hittable_list objects;
22352223

22362224
auto red = make_shared<lambertian>(color(.65, .05, .05));
22372225
auto white = make_shared<lambertian>(color(.73, .73, .73));
22382226
auto green = make_shared<lambertian>(color(.12, .45, .15));
22392227
auto light = make_shared<diffuse_light>(color(15, 15, 15));
22402228

2241-
world.add(make_shared<yz_rect>(0, 555, 0, 555, 555, green));
2242-
world.add(make_shared<yz_rect>(0, 555, 0, 555, 0, red));
2243-
world.add(make_shared<xz_rect>(213, 343, 227, 332, 554, light));
2244-
world.add(make_shared<xz_rect>(0, 555, 0, 555, 555, white));
2245-
world.add(make_shared<xz_rect>(0, 555, 0, 555, 0, white));
2246-
world.add(make_shared<xy_rect>(0, 555, 0, 555, 555, white));
2229+
objects.add(make_shared<yz_rect>(0, 555, 0, 555, 555, green));
2230+
objects.add(make_shared<yz_rect>(0, 555, 0, 555, 0, red));
2231+
objects.add(make_shared<flip_face>(make_shared<xz_rect>(213, 343, 227, 332, 554, light)));
2232+
objects.add(make_shared<xz_rect>(0, 555, 0, 555, 555, white));
2233+
objects.add(make_shared<xz_rect>(0, 555, 0, 555, 0, white));
2234+
objects.add(make_shared<xy_rect>(0, 555, 0, 555, 555, white));
22472235

22482236

22492237
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
@@ -2252,25 +2240,15 @@
22522240
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
22532241
box1 = make_shared<rotate_y>(box1, 15);
22542242
box1 = make_shared<translate>(box1, vec3(265,0,295));
2255-
world.add(box1);
2256-
2257-
shared_ptr<hittable> box2 = make_shared<box>(point3(0,0,0), point3(165,165,165), white);
2258-
box2 = make_shared<rotate_y>(box2, -18);
2259-
box2 = make_shared<translate>(box2, vec3(130,0,65);
2260-
world.add(box2);
2243+
objects.add(box1);
22612244

2262-
point3 lookfrom(278, 278, -800);
2263-
point3 lookat(278, 278, 0);
2264-
vec3 vup(0, 1, 0);
2265-
auto dist_to_focus = 10.0;
2266-
auto aperture = 0.0;
2267-
auto vfov = 40.0;
2268-
auto time0 = 0.0;
2269-
auto time1 = 1.0;
22702245

2271-
cam = camera(lookfrom, lookat, vup, vfov, aspect, aperture, dist_to_focus, time0, time1);
2246+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
2247+
auto glass = make_shared<dielectric>(1.5);
2248+
objects.add(make_shared<sphere>(point3(190,90,190), 90 , glass));
2249+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
22722250

2273-
return world;
2251+
return objects;
22742252
}
22752253
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22762254
[Listing [scene-cornell-al]: <kbd>[main.cc]</kbd> Cornell box scene with aluminum material]
@@ -2511,6 +2489,7 @@
25112489
auto g = pixel_color.y();
25122490
auto b = pixel_color.z();
25132491

2492+
25142493
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
25152494
// Replace NaN components with zero. See explanation in Ray Tracing: The Rest of Your Life.
25162495
if (r != r) r = 0.0;

src/TheNextWeek/main.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ hittable_list cornell_box() {
150150
auto red = make_shared<lambertian>(color(.65, .05, .05));
151151
auto white = make_shared<lambertian>(color(.73, .73, .73));
152152
auto green = make_shared<lambertian>(color(.12, .45, .15));
153-
auto light = make_shared<diffuse_light>(color(15,15,15));
153+
auto light = make_shared<diffuse_light>(color(15, 15, 15));
154154

155155
objects.add(make_shared<yz_rect>(0, 555, 0, 555, 555, green));
156156
objects.add(make_shared<yz_rect>(0, 555, 0, 555, 0, red));

src/TheRestOfYourLife/aarect.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class xz_rect : public hittable {
5555
return true;
5656
}
5757

58-
virtual double pdf_value(const point3& origin, const vec3& v) const {
58+
virtual double pdf_value(const point3& origin, const vec3& v) const override {
5959
hit_record rec;
6060
if (!this->hit(ray(origin, v), 0.001, infinity, rec))
6161
return 0;
@@ -67,7 +67,7 @@ class xz_rect : public hittable {
6767
return distance_squared / (cosine * area);
6868
}
6969

70-
virtual vec3 random(const point3& origin) const {
70+
virtual vec3 random(const point3& origin) const override {
7171
auto random_point = point3(random_double(x0,x1), k, random_double(z0,z1));
7272
return random_point - origin;
7373
}

0 commit comments

Comments
 (0)