Skip to content

Commit

Permalink
Fixed random_on_hemisphere mistake and small english touch ups
Browse files Browse the repository at this point in the history
  • Loading branch information
Trevor Black authored and hollasch committed Nov 25, 2019
1 parent d121a4d commit fa0022a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions books/RayTracingInOneWeekend.html
Original file line number Diff line number Diff line change
Expand Up @@ -1285,7 +1285,7 @@
1. The shadows are less pronounced after the change
2. Both spheres are lighter in appearance after the change

Both of these changes are due to the more even scattering of the light rays, less rays are
Both of these changes are due to the more uniform scattering of the light rays, less rays are
scattering toward the normal. This means that for diffuse objects they will appear _lighter_
because more light bounces toward the camera. For the shadows, less of the light bounces
straight-up, so the parts of the larger sphere directly underneath the smaller sphere are brighter.
Expand Down Expand Up @@ -1325,7 +1325,12 @@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[Listing [random-in-hemisphere]: <kbd>[material.h]</kbd> The random_in_hemisphere(normal) function]

And plugging the new formula into the `ray_color()` function:
Note that the functionality should be identical between `random_in_unit_sphere()` and
`random_on_unit_sphere()`
</div>

<div class='together'>
Plugging the new formula into the `ray_color()` function:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
vec3 ray_color(const ray& r, hittable *world, int depth) {
Expand All @@ -1334,7 +1339,7 @@
if (depth <= 0)
return vec3(0,0,0);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
vec3 target = rec.p + random_on_hemisphere(rec.normal);
vec3 target = rec.p + random_in_hemisphere(rec.normal);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
return 0.5 * ray_color(ray(rec.p, target - rec.p), world, depth-1);
}
Expand Down

0 comments on commit fa0022a

Please sign in to comment.