Skip to content

Commit 47837c5

Browse files
committed
Update fuzzy reflection rays
This change updates the fuzzy reflection figure and code to use `random_unit_vector()` instead of `random_in_unit_sphere()` for fuzzy reflection rays.
1 parent 3fd8750 commit 47837c5

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

books/RayTracingInOneWeekend.html

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2684,9 +2684,12 @@
26842684
-----------------
26852685
<div class='together'>
26862686
We can also randomize the reflected direction by using a small sphere and choosing a new endpoint
2687-
for the ray:
2687+
for the ray.
2688+
We'll use a random point from the surface of a sphere centered on the original endpoint, scaled by
2689+
the fuzz factor.
26882690

2689-
![Figure [reflect-fuzzy]: Generating fuzzed reflection rays](../images/fig-1.12-reflect-fuzzy.jpg)
2691+
![Figure [reflect-fuzzy]: Generating fuzzed reflection rays
2692+
](../images/fig-1.12-reflect-fuzzy.jpg)
26902693

26912694
</div>
26922695

@@ -2707,7 +2710,7 @@
27072710
const override {
27082711
vec3 reflected = reflect(unit_vector(r_in.direction()), rec.normal);
27092712
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
2710-
scattered = ray(rec.p, reflected + fuzz*random_in_unit_sphere());
2713+
scattered = ray(rec.p, reflected + fuzz*random_unit_vector());
27112714
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
27122715
attenuation = albedo;
27132716
return (dot(scattered.direction(), rec.normal) > 0);

images/fig-1.12-reflect-fuzzy.jpg

51.7 KB
Loading

0 commit comments

Comments
 (0)