Skip to content

Commit 7e94361

Browse files
committed
Edit pass: fix many conjunctions
Generally adding commas before many conjunctions, rewording some sentences that begin with a conjunction. I did not apply these changes uniformly, particlularly where they would have messed with the tone of the original text.
1 parent 5111229 commit 7e94361

File tree

3 files changed

+114
-114
lines changed

3 files changed

+114
-114
lines changed

books/RayTracingInOneWeekend.html

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
====================================================================================================
1818

1919
I’ve taught many graphics classes over the years. Often I do them in ray tracing, because you are
20-
forced to write all the code but you can still get cool images with no API. I decided to adapt my
20+
forced to write all the code, but you can still get cool images with no API. I decided to adapt my
2121
course notes into a how-to, to get you to a cool program as quickly as possible. It will not be a
2222
full-featured ray tracer, but it does have the indirect lighting which has made ray tracing a staple
2323
in movies. Follow these steps, and the architecture of the ray tracer you produce will be good for
@@ -33,8 +33,8 @@
3333
don’t need to. However, I suggest you do, because it’s fast, portable, and most production movie and
3434
video game renderers are written in C++. Note that I avoid most “modern features” of C++, but
3535
inheritance and operator overloading are too useful for ray tracers to pass on. I do not provide the
36-
code online, but the code is real and I show all of it except for a few straightforward operators in
37-
the `vec3` class. I am a big believer in typing in code to learn it, but when code is available I
36+
code online, but the code is real, and I show all of it except for a few straightforward operators
37+
in the `vec3` class. I am a big believer in typing in code to learn it, but when code is available I
3838
use it, so I only practice what I preach when the code is not available. So don’t ask!
3939

4040
I have left that last part in because it is funny what a 180 I have done. Several readers ended up
@@ -64,7 +64,7 @@
6464
====================================================================================================
6565

6666
Whenever you start a renderer, you need a way to see an image. The most straightforward way is to
67-
write it to a file. The catch is, there are so many formats and many of those are complex. I always
67+
write it to a file. The catch is, there are so many formats, and many of those are complex. I always
6868
start with a plain text ppm file. Here’s a nice description from Wikipedia:
6969

7070
![](../images/img.ppm-example.jpg)
@@ -140,7 +140,7 @@
140140

141141
<div class='together'>
142142
Hooray! This is the graphics “hello world”. If your image doesn’t look like that, open the output
143-
file in a text editor and see what it looks like. It should start something like this:
143+
file in a text editor, and see what it looks like. It should start something like this:
144144

145145
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
146146
P3
@@ -171,7 +171,7 @@
171171
loop or other problem.
172172

173173
<div class='together'>
174-
Our program outputs the image to the standard output stream (`std::cout`), so leave that alone and
174+
Our program outputs the image to the standard output stream (`std::cout`), so leave that alone, and
175175
instead write to the error output stream (`std::cerr`):
176176

177177
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
@@ -357,7 +357,7 @@
357357
<div class='together'>
358358
The one thing that all ray tracers have is a ray class, and a computation of what color is seen
359359
along a ray. Let’s think of a ray as a function $\mathbf{p}(t) = \mathbf{a} + t \vec{\mathbf{b}}$.
360-
Here $\mathbf{p}$ is a 3D position along a line in 3D. $\mathbf{a}$ is the ray origin and
360+
Here $\mathbf{p}$ is a 3D position along a line in 3D. $\mathbf{a}$ is the ray origin, and
361361
$\vec{\mathbf{b}}$ is the ray direction. The ray parameter $t$ is a real number (`double` in the
362362
code). Plug in a different $t$ and $p(t)$ moves the point along the ray. Add in negative $t$ and you
363363
can go anywhere on the 3D line. For positive $t$, you get only the parts in front of $\mathbf{a}$,
@@ -401,7 +401,7 @@
401401
</div>
402402

403403
Now we are ready to turn the corner and make a ray tracer. At the core, the ray tracer sends rays
404-
through pixels and computes the color seen in the direction of those rays. The involved steps are
404+
through pixels, and computes the color seen in the direction of those rays. The involved steps are
405405
(1) calculate the ray from the eye to the pixel, (2) determine which objects the ray intersects, and
406406
(3) compute a color for that intersection point. When first developing a ray tracer, I always do a
407407
simple camera for getting the code up and running. I also make a simple `color(ray)` function that
@@ -411,7 +411,7 @@
411411
often, so I’ll stick with a 200×100 image. I’ll put the “eye” (or camera center if you think of a
412412
camera) at $(0,0,0)$. I will have the y-axis go up, and the x-axis to the right. In order to respect
413413
the convention of a right handed coordinate system, into the screen is the negative z-axis. I will
414-
traverse the screen from the lower left hand corner and use two offset vectors along the screen
414+
traverse the screen from the lower left hand corner, and use two offset vectors along the screen
415415
sides to move the ray endpoint across the screen. Note that I do not make the ray direction a unit
416416
length vector because I think not doing that makes for simpler and slightly faster code.
417417

@@ -535,7 +535,7 @@
535535
</div>
536536

537537
<div class='together'>
538-
The rules of vector algebra are all that we would want here, and if we expand that equation and
538+
The rules of vector algebra are all that we would want here, and if we expand that equation, and
539539
move all the terms to the left hand side we get:
540540

541541
$$ t^2 \vec{\mathbf{b}}\cdot\vec{\mathbf{b}}
@@ -715,11 +715,11 @@
715715

716716

717717
Now, how about several spheres? While it is tempting to have an array of spheres, a very clean
718-
solution is the make an “abstract class” for anything a ray might hit and make both a sphere and a
718+
solution is the make an “abstract class” for anything a ray might hit, and make both a sphere and a
719719
list of spheres just something you can hit. What that class should be called is something of a
720720
quandary -- calling it an “object” would be good if not for “object oriented” programming. “Surface”
721721
is often used, with the weakness being maybe we will want volumes. “hittable” emphasizes the member
722-
function that unites them. I don’t love any of these but I will go with “hittable”.
722+
function that unites them. I don’t love any of these, but I will go with “hittable”.
723723

724724
<div class='together'>
725725
This `hittable` abstract class will have a hit function that takes in a ray. Most ray tracers have
@@ -864,10 +864,10 @@
864864
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
865865
[Listing [normals-point-against]: <kbd>[sphere.h]</kbd> Remembering the side of the surface]
866866

867-
The decision whether to have normals always point out or always point against the ray is based on
867+
The decision whether to have normals always point out or to always point against the ray is based on
868868
whether you want to determine the side of the surface at the time of geometry or at the time of
869869
coloring. In this book we have more material types than we have geometry types, so we'll go for
870-
less work and put the determination at geometry time. This is simply a matter of preference and
870+
less work, and put the determination at geometry time. This is simply a matter of preference, and
871871
you'll see both implementations in the literature.
872872

873873
We add the `front_face` bool to the `hit_record` struct. I know that we’ll also want motion blur at
@@ -1029,7 +1029,7 @@
10291029

10301030
We'll use shared pointers in our code, because it allows multiple geometries to share a common
10311031
instance (for example, a bunch of spheres that all use the same texture map material), and because
1032-
it makes memory management automatic and easier to reason about.
1032+
it makes memory management automatic, and easier to reason about.
10331033

10341034
`std::shared_ptr` is included with the `<memory>` header.
10351035

@@ -1178,10 +1178,10 @@
11781178

11791179
When a real camera takes a picture, there are usually no jaggies along edges because the edge pixels
11801180
are a blend of some foreground and some background. We can get the same effect by averaging a bunch
1181-
of samples inside each pixel. We will not bother with stratification, which is controversial but is
1181+
of samples inside each pixel. We will not bother with stratification, which is controversial, but is
11821182
usual for my programs. For some ray tracers it is critical, but the kind of general one we are
1183-
writing doesn’t benefit very much from it and it makes the code uglier. We abstract the camera class
1184-
a bit so we can make a cooler camera later.
1183+
writing doesn’t benefit very much from it, and it makes the code uglier. We abstract the camera
1184+
class a bit so we can make a cooler camera later.
11851185

11861186
One thing we need is a random number generator that returns real random numbers. We need a function
11871187
that returns a canonical random number which by convention returns random real in the range
@@ -1384,8 +1384,8 @@
13841384
ideal diffuse surfaces. (I used to do it as a lazy hack that approximates mathematically ideal
13851385
Lambertian.)
13861386

1387-
(Reader Vassillen Chizhov proved that the lazy hack is indeed just a lazy hack and is inaccurate.
1388-
The correct representation of ideal Lambertian isn't much more work and is presented at the end of
1387+
(Reader Vassillen Chizhov proved that the lazy hack is indeed just a lazy hack, and is inaccurate.
1388+
The correct representation of ideal Lambertian isn't much more work, and is presented at the end of
13891389
the chapter.)
13901390

13911391
<div class='together'>
@@ -1394,7 +1394,7 @@
13941394
sphere with a center at $(p - \vec{N})$ is considered _inside_ the surface, whereas the sphere with
13951395
center $(p + \vec{N})$ is considered _outside_ the surface. Select the tangent unit radius sphere
13961396
that is on the same side of the surface as the ray origin. Pick a random point $s$ inside this unit
1397-
radius sphere and send a ray from the hit point $p$ to the random point $s$ (this is the vector
1397+
radius sphere, and send a ray from the hit point $p$ to the random point $s$ (this is the vector
13981398
$(s-p)$):
13991399

14001400
![Figure [rand-vector]: Generating a random diffuse bounce ray](../images/fig.rand-vector.jpg)
@@ -1404,7 +1404,7 @@
14041404
<div class='together'>
14051405
We need a way to pick a random point in a unit radius sphere. We’ll use what is usually the easiest
14061406
algorithm: a rejection method. First, pick a random point in the unit cube where x, y, and z all
1407-
range from -1 to +1. Reject this point and try again if the point is outside the sphere.
1407+
range from -1 to +1. Reject this point, and try again if the point is outside the sphere.
14081408

14091409
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
14101410
class vec3 {
@@ -1869,7 +1869,7 @@
18691869

18701870
<div class='together'>
18711871
For the Lambertian (diffuse) case we already have, it can either scatter always and attenuate by its
1872-
reflectance $R$, or it can scatter with no attenuation but absorb the fraction $1-R$ of the rays. Or
1872+
reflectance $R$, or it can scatter with no attenuation but absorb the fraction $1-R$ of the rays, or
18731873
it could be a mixture of those strategies. For Lambertian materials we get this simple class:
18741874

18751875
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
@@ -2030,7 +2030,7 @@
20302030
</div>
20312031

20322032
<div class='together'>
2033-
We can also randomize the reflected direction by using a small sphere and choosing a new endpoint
2033+
We can also randomize the reflected direction by using a small sphere, and choosing a new endpoint
20342034
for the ray:
20352035

20362036
![Figure [reflect-fuzzy]: Generating fuzzed reflection rays](../images/fig.reflect-fuzzy.jpg)
@@ -2090,7 +2090,7 @@
20902090

20912091
Clear materials such as water, glass, and diamonds are dielectrics. When a light ray hits them, it
20922092
splits into a reflected ray and a refracted (transmitted) ray. We’ll handle that by randomly
2093-
choosing between reflection or refraction and only generating one scattered ray per interaction.
2093+
choosing between reflection or refraction, and only generating one scattered ray per interaction.
20942094

20952095
<div class='together'>
20962096
The hardest part to debug is the refracted ray. I usually first just have all the light refract if
@@ -2107,7 +2107,7 @@
21072107

21082108
Is that right? Glass balls look odd in real life. But no, it isn’t right. The world should be
21092109
flipped upside down and no weird black stuff. I just printed out the ray straight through the middle
2110-
of the image and it was clearly wrong. That often does the job.
2110+
of the image, and it was clearly wrong. That often does the job.
21112111

21122112
<div class='together'>
21132113
The refraction is described by Snell’s law:
@@ -2208,7 +2208,7 @@
22082208

22092209
<div class='together'>
22102210
That definitely doesn't look right. One troublesome practical issue is that when the ray is in the
2211-
material with the higher refractive index, there is no real solution to Snell’s law and thus there
2211+
material with the higher refractive index, there is no real solution to Snell’s law, and thus there
22122212
is no refraction possible. If we refer back to Snell's law and the derivation of $\sin\theta'$:
22132213

22142214
$$ \sin\theta' = \frac{\eta}{\eta'} \cdot \sin\theta $$
@@ -2221,8 +2221,8 @@
22212221

22222222
$$ \frac{1.5}{1.0} \cdot \sin\theta > 1.0 $$
22232223

2224-
The equality between the two sides of the equation is broken and a solution cannot exist. If a
2225-
solution does not exist the glass cannot refract and must reflect the ray:
2224+
The equality between the two sides of the equation is broken, and a solution cannot exist. If a
2225+
solution does not exist the glass cannot refract, and must reflect the ray:
22262226

22272227
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
22282228
if(etai_over_etat * sin_theta > 1.0) {
@@ -2386,7 +2386,7 @@
23862386

23872387
<div class='together'>
23882388
An interesting and easy trick with dielectric spheres is to note that if you use a negative radius,
2389-
the geometry is unaffected but the surface normal points inward, so it can be used as a bubble
2389+
the geometry is unaffected, but the surface normal points inward, so it can be used as a bubble
23902390
to make a hollow glass sphere:
23912391

23922392
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
@@ -2507,7 +2507,7 @@
25072507

25082508
Remember that `vup`, `v`, and `w` are all in the same plane. Note that, like before when our fixed
25092509
camera faced -Z, our arbitrary view camera faces -w. And keep in mind that we can -- but we don’t
2510-
have to -- use world up (0,1,0) to specify vup. This is convenient and will naturally keep your
2510+
have to -- use world up (0,1,0) to specify vup. This is convenient, and will naturally keep your
25112511
camera horizontally level until you decide to experiment with crazy camera angles.
25122512

25132513
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
@@ -2606,8 +2606,8 @@
26062606

26072607
<div class="together">
26082608
A real camera has a complicated compound lens. For our code we could simulate the order: sensor,
2609-
then lens, then aperture, and figure out where to send the rays and flip the image once computed
2610-
(the image is projected upside down on the film). Graphics people usually use a thin lens
2609+
then lens, then aperture. Then we could figure out where to send the rays, and flip the image once
2610+
computed (the image is projected upside down on the film). Graphics people usually use a thin lens
26112611
approximation:
26122612

26132613
![Figure [cam-lens]: Camera lens model](../images/fig.cam-lens.jpg)
@@ -2804,7 +2804,7 @@
28042804

28052805
An interesting thing you might note is the glass balls don’t really have shadows which makes them
28062806
look like they are floating. This is not a bug (you don’t see glass balls much in real life, where
2807-
they also look a bit strange and indeed seem to float on cloudy days). A point on the big sphere
2807+
they also look a bit strange, and indeed seem to float on cloudy days). A point on the big sphere
28082808
under a glass ball still has lots of light hitting it because the sky is re-ordered rather than
28092809
blocked.
28102810

@@ -2816,16 +2816,16 @@
28162816
2. Biasing scattered rays toward them, and then downweighting those rays to cancel out the bias.
28172817
Both work. I am in the minority in favoring the latter approach.
28182818

2819-
3. Triangles. Most cool models are in triangle form. The model I/O is the worst and almost
2819+
3. Triangles. Most cool models are in triangle form. The model I/O is the worst, and almost
28202820
everybody tries to get somebody else’s code to do this.
28212821

2822-
4. Surface textures. This lets you paste images on like wall paper. Pretty easy and a good thing
2822+
4. Surface textures. This lets you paste images on like wall paper. Pretty easy, and a good thing
28232823
to do.
28242824

28252825
5. Solid textures. Ken Perlin has his code online. Andrew Kensler has some very cool info at his
28262826
blog.
28272827

2828-
6. Volumes and media. Cool stuff and will challenge your software architecture. I favor making
2828+
6. Volumes and media. Cool stuff, and will challenge your software architecture. I favor making
28292829
volumes have the hittable interface and probabilistically have intersections based on density.
28302830
Your rendering code doesn’t even have to know it has volumes with that method.
28312831

0 commit comments

Comments
 (0)