Skip to content

Commit 45a7162

Browse files
authored
Merge pull request #903 from RayTracing/shadow_acne_context
Added the source around the shadow acne ellipse for context
2 parents e2e6c83 + 8174647 commit 45a7162

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-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: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1853,7 +1853,25 @@
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+
// If we've exceeded the ray bounce limit, no more light is gathered.
1860+
if (depth <= 0)
1861+
return color(0,0,0);
1862+
1863+
1864+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
1865+
if (world.hit(r, interval(0.001, infinity), rec)) {
1866+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
1867+
point3 target = rec.p + rec.normal + random_in_unit_sphere();
1868+
return 0.5 * ray_color(ray(rec.p, target - rec.p), world, depth-1);
1869+
}
1870+
1871+
vec3 unit_direction = unit_vector(r.direction());
1872+
auto t = 0.5*(unit_direction.y() + 1.0);
1873+
return (1.0-t)*color(1.0, 1.0, 1.0) + t*color(0.5, 0.7, 1.0);
1874+
}
18571875
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
18581876
[Listing [reflect-tolerance]: <kbd>[main.cc]</kbd>
18591877
Calculating reflected ray origins with tolerance]

0 commit comments

Comments
 (0)