Skip to content

Commit d5f8ff4

Browse files
committed
Tweak sphere-intersect code
1. Tighten the highlighting on changed `ray_color()` function in listing "Ray color with scattered reflectance". 2. Remove extraneous remark about needed to add a material pointer to the sphere class -- this has already been done at this point in the text. Resolves #355
1 parent a91ef50 commit d5f8ff4

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

books/RayTracingInOneWeekend.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,7 @@
652652
</div>
653653

654654
Let’s revisit the ray-sphere equation:
655+
655656
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
656657
vec3 oc = r.origin() - center;
657658
auto a = dot(r.direction(), r.direction());
@@ -1762,6 +1763,7 @@
17621763
shared_ptr<material> mat_ptr;
17631764
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
17641765
};
1766+
17651767
bool sphere::hit(const ray& r, double t_min, double t_max, hit_record& rec) const {
17661768
vec3 oc = r.origin() - center;
17671769
auto a = r.direction().length_squared();
@@ -1883,9 +1885,11 @@
18831885
hit_record rec;
18841886
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
18851887
if (world.hit(r, 0.001, infinity, rec)) {
1888+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
18861889
// If we've exceeded the ray bounce limit, no more light is gathered.
18871890
if (depth <= 0)
18881891
return vec3(0,0,0);
1892+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
18891893
ray scattered;
18901894
vec3 attenuation;
18911895
if (rec.mat_ptr->scatter(r, rec, attenuation, scattered))
@@ -1903,8 +1907,7 @@
19031907
</div>
19041908

19051909
<div class='together'>
1906-
You will also need to modify the sphere class to have a material pointer to it. And add some
1907-
metal spheres:
1910+
Now let’s add some metal spheres to our scene:
19081911

19091912
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
19101913
int main() {

0 commit comments

Comments
 (0)