Skip to content

Commit 0571bc9

Browse files
committed
Added the source around the shadow acne ellipse for context
1 parent e2e6c83 commit 0571bc9

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Change Log -- Ray Tracing in One Weekend
2626

2727
### In One Weekend
2828
- Added: More commentary about the choice between `double` and `float` (#752)
29+
- Added: Software context around the shadow acne listing
2930

3031
### The Next Week
3132
- Change: Rearranged the texture-mapping presentation. The three types (solid, spatial, image) are

books/RayTracingInOneWeekend.html

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1853,7 +1853,26 @@
18531853
point approximation the sphere intersector gives us. So we need to ignore hits very near zero:
18541854

18551855
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
1856-
if (world.hit(r, interval(0.001, infinity), rec)) {
1856+
color ray_color(const ray& r, const hittable& world, int depth) {
1857+
hit_record rec;
1858+
1859+
1860+
// If we've exceeded the ray bounce limit, no more light is gathered.
1861+
if (depth <= 0)
1862+
return color(0,0,0);
1863+
1864+
1865+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
1866+
if (world.hit(r, interval(0.001, infinity), rec)) {
1867+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
1868+
point3 target = rec.p + rec.normal + random_in_unit_sphere();
1869+
return 0.5 * ray_color(ray(rec.p, target - rec.p), world, depth-1);
1870+
}
1871+
1872+
vec3 unit_direction = unit_vector(r.direction());
1873+
auto t = 0.5*(unit_direction.y() + 1.0);
1874+
return (1.0-t)*color(1.0, 1.0, 1.0) + t*color(0.5, 0.7, 1.0);
1875+
}
18571876
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
18581877
[Listing [reflect-tolerance]: <kbd>[main.cc]</kbd>
18591878
Calculating reflected ray origins with tolerance]

0 commit comments

Comments
 (0)