Skip to content

Commit b98d19a

Browse files
committed
Avoid hittable_list of lights until ready
The previous version didn't work be we hadn't yet added the `pdf_value()` and `random` functions to the `hittable_list` class, so all of these scenes (images 3.10-13) rendered as fully dark. Resolves #1318
1 parent b59e8f0 commit b98d19a

6 files changed

+11
-13
lines changed

books/RayTracingTheRestOfYourLife.html

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3098,9 +3098,8 @@
30983098

30993099
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
31003100
// Light Sources
3101-
hittable_list lights;
3102-
auto m = shared_ptr<material>();
3103-
lights.add(make_shared<quad>(point3(343,554,332), vec3(-130,0,0), vec3(0,0,-105), m));
3101+
auto empty_material = shared_ptr<material>();
3102+
quad lights(point3(343,554,332), vec3(-130,0,0), vec3(0,0,-105), empty_material);
31043103
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
31053104

31063105
camera cam;
@@ -3638,9 +3637,8 @@
36383637
world.add(box2);
36393638

36403639
// Light Sources
3641-
hittable_list lights;
3642-
auto m = shared_ptr<material>();
3643-
lights.add(make_shared<quad>(point3(343,554,332), vec3(-130,0,0), vec3(0,0,-105), m));
3640+
auto empty_material = shared_ptr<material>();
3641+
quad lights(point3(343,554,332), vec3(-130,0,0), vec3(0,0,-105), empty_material);
36443642

36453643
...
36463644
}
@@ -3809,9 +3807,8 @@
38093807
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
38103808

38113809
// Light Sources
3812-
hittable_list lights;
3813-
auto m = shared_ptr<material>();
3814-
lights.add(make_shared<quad>(point3(343,554,332), vec3(-130,0,0), vec3(0,0,-105), m));
3810+
auto empty_material = shared_ptr<material>();
3811+
quad lights(point3(343,554,332), vec3(-130,0,0), vec3(0,0,-105), empty_material);
38153812

38163813
...
38173814
}
@@ -3867,17 +3864,18 @@
38673864
[Listing [density-mixture]: <kbd>[hittable_list.h]</kbd> Creating a mixture of densities]
38683865

38693866
<div class='together'>
3870-
We assemble a list to pass to `render()` from `main()`:
3867+
We assemble a list of light sources to pass to `camera::render()`:
38713868

38723869
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
38733870
int main() {
38743871
...
38753872

38763873
// Light Sources
3877-
hittable_list lights;
3878-
auto m = shared_ptr<material>();
3879-
lights.add(make_shared<quad>(point3(343,554,332), vec3(-130,0,0), vec3(0,0,-105), m));
3874+
auto empty_material = shared_ptr<material>();
38803875
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
3876+
hittable_list lights;
3877+
lights.add(
3878+
make_shared<quad>(point3(343,554,332), vec3(-130,0,0), vec3(0,0,-105), empty_material));
38813879
lights.add(make_shared<sphere>(point3(190, 90, 190), 90, m));
38823880
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
38833881

images/img-3.10-hittable-light.jpg

49.9 KB
Loading

images/img-3.11-cosine-and-light.jpg

77.9 KB
Loading

images/img-3.12-arbitrary-pdf.jpg

92.2 KB
Loading
86.6 KB
Loading

images/img-3.14-glass-and-light.jpg

10 KB
Loading

0 commit comments

Comments
 (0)