Skip to content

Commit cc2d5d8

Browse files
committed
Image + figure renumbering
The original books start with the overview numbered as chapter 0, but Markdeep automatically numbers chapters beginning at chapter 1. This means that all figure and image names have to be incremented. This change renames the actual image files, as well as their references and names in the text.
1 parent 1531760 commit cc2d5d8

File tree

101 files changed

+85
-85
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+85
-85
lines changed

books/RayTracingInOneWeekend.html

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
write it to a file. The catch is, there are so many formats and many of those are complex. I always
6767
start with a plain text ppm file. Here’s a nice description from Wikipedia:
6868

69-
![Image 1-1: PPM Example](../images/img-1-01-1.jpg)
69+
![Image 2-1: PPM Example](../images/img-1-02-1.jpg)
7070

7171
Let’s make some C++ code to output such a thing:
7272

@@ -108,7 +108,7 @@
108108
Opening the output file (in ToyViewer on my mac, but try it in your favorite viewer and google “ppm
109109
viewer” if your viewer doesn’t support it) shows:
110110

111-
![Image 1-2](../images/img-1-01-2.jpg)
111+
![Image 2-2](../images/img-1-02-2.jpg)
112112

113113
Hooray! This is the graphics “hello world”. If your image doesn’t look like that, open the output
114114
file in a text editor and see what it looks like. It should start something like this:
@@ -332,7 +332,7 @@
332332
front of $A$, and this is what is often called a half-line or ray. The example $C = p(2)$ is shown
333333
here:
334334

335-
![Figure 3-1](../images/fig-1-03-1.jpg)
335+
![Figure 4-1](../images/fig-1-04-1.jpg)
336336

337337
The function $p(t)$ in more verbose code form I call “point_at_parameter(t)”:
338338

@@ -372,7 +372,7 @@
372372
sides to move the ray endpoint across the screen. Note that I do not make the ray direction a unit
373373
length vector because I think not doing that makes for simpler and slightly faster code.
374374

375-
![Figure 3-2](../images/fig-1-03-2.jpg)
375+
![Figure 4-2](../images/fig-1-04-2.jpg)
376376

377377
Below in code, the ray $r$ goes to approximately the pixel centers (I won’t worry about exactness
378378
for now because we’ll add antialiasing later):
@@ -421,7 +421,7 @@
421421

422422
with $t$ going from zero to one. In our case this produces:
423423

424-
![Image 3-1](../images/img-1-03-1.jpg)
424+
![Image 4-1](../images/img-1-04-1.jpg)
425425

426426

427427

@@ -467,7 +467,7 @@
467467
(meaning no real solutions), or zero (meaning one real solution). In graphics, the algebra almost
468468
always relates very directly to the geometry. What we have is:
469469

470-
![Figure 4-1](../images/fig-1-04-1.jpg)
470+
![Figure 5-1](../images/fig-1-05-1.jpg)
471471

472472
If we take that math and hard-code it into our program, we can test it by coloring red any pixel
473473
that hits a small sphere we place at -1 on the z-axis:
@@ -493,7 +493,7 @@
493493

494494
What we get is this:
495495

496-
![Image 4-1](../images/img-1-04-1.jpg)
496+
![Image 5-1](../images/img-1-05-1.jpg)
497497

498498
Now this lacks all sorts of things -- like shading and reflection rays and more than one object --
499499
but we are closer to halfway done than we are to our start! One thing to be aware of is that we
@@ -513,7 +513,7 @@
513513
as are most design decisions like that. For a sphere, the normal is in the direction of the hitpoint
514514
minus the center:
515515

516-
![Figure 5-1](../images/fig-1-05-1.jpg)
516+
![Figure 6-1](../images/fig-1-06-1.jpg)
517517

518518
On the earth, this implies that the vector from the earth’s center to you points straight up. Let’s
519519
throw that into the code now, and shade it. We don’t have any lights or anything yet, so let’s just
@@ -552,7 +552,7 @@
552552

553553
And that yields this picture:
554554

555-
![Image 5-1](../images/img-1-05-1.jpg)
555+
![Image 6-1](../images/img-1-06-1.jpg)
556556

557557
Now, how about several spheres? While it is tempting to have an array of spheres, a very clean
558558
solution is the make an “abstract class” for anything a ray might hit and make both a sphere and a
@@ -728,7 +728,7 @@
728728
This yields a picture that is really just a visualization of where the spheres are along with their
729729
surface normal. This is often a great way to look at your model for flaws and characteristics.
730730

731-
![Image 5-2](../images/img-1-05-2.jpg)
731+
![Image 6-2](../images/img-1-06-2.jpg)
732732

733733

734734

@@ -786,7 +786,7 @@
786786
For a given pixel we have several samples within that pixel and send rays through each of the
787787
samples. The colors of these rays are then averaged:
788788

789-
![Figure 6-1](../images/fig-1-06-1.jpg)
789+
![Figure 7-1](../images/fig-1-07-1.jpg)
790790

791791
Putting that all together yields a camera class encapsulating our simple axis-aligned camera from
792792
before:
@@ -853,7 +853,7 @@
853853
Zooming into the image that is produced, the big change is in edge pixels that are part background
854854
and part foreground:
855855

856-
![Image 6-1](../images/img-1-06-1.jpg)
856+
![Image 7-1](../images/img-1-07-1.jpg)
857857

858858

859859

@@ -872,7 +872,7 @@
872872
direction randomized. So, if we send three rays into a crack between two diffuse surfaces they will
873873
each have different random behavior:
874874

875-
![Figure 7-1](../images/fig-1-07-1.jpg)
875+
![Figure 8-1](../images/fig-1-08-1.jpg)
876876

877877
They also might be absorbed rather than reflected. The darker the surface, the more likely
878878
absorption is. (That’s why it is dark!) Really any algorithm that randomizes direction will produce
@@ -883,7 +883,7 @@
883883
Pick a random point s from the unit radius sphere that is tangent to the hitpoint, and send a ray
884884
from the hitpoint $p$ to the random point $s$. That sphere has center $(p + N)$:
885885

886-
![Figure 7-2](../images/fig-1-07-2.jpg)
886+
![Figure 8-2](../images/fig-1-08-2.jpg)
887887

888888
We also need a way to pick a random point in a unit radius sphere centered at the origin. We’ll use
889889
what is usually the easiest algorithm: a rejection method. First, we pick a random point in the unit
@@ -917,7 +917,7 @@
917917

918918
This gives us:
919919

920-
![Image 7-1](../images/img-1-07-1.jpg)
920+
![Image 8-1](../images/img-1-08-1.jpg)
921921

922922
Note the shadowing under the sphere. This picture is very dark, but our spheres only absorb half the
923923
energy on each bounce, so they are 50% reflectors. If you can’t see the shadow, don’t worry, we will
@@ -939,7 +939,7 @@
939939

940940
That yields light grey, as we desire:
941941

942-
![Image 7-2](../images/img-1-07-2.jpg)
942+
![Image 8-2](../images/img-1-08-2.jpg)
943943

944944
There’s also a subtle bug in there. Some of the reflected rays hit the object they are reflecting
945945
off of not at exactly $t=0$, but instead at $t=-0.0000001$ or $t=0.00000001$ or whatever floating
@@ -1082,7 +1082,7 @@
10821082
For smooth metals the ray won’t be randomly scattered. The key math is: how does a ray get
10831083
reflected from a metal mirror? Vector math is our friend here:
10841084

1085-
![Figure 8-1](../images/fig-1-08-1.jpg)
1085+
![Figure 9-1](../images/fig-1-09-1.jpg)
10861086

10871087
The reflected ray direction in red is just $(v + 2B)$. In our design, $N$ is a unit vector, but $v$
10881088
may not be. The length of $B$ should be $dot(v,N)$. Because $v$ points in, we will need a minus
@@ -1174,12 +1174,12 @@
11741174

11751175
Which gives:
11761176

1177-
![Image 8-1](../images/img-1-08-1.jpg)
1177+
![Image 9-1](../images/img-1-09-1.jpg)
11781178

11791179
We can also randomize the reflected direction by using a small sphere and choosing a new endpoint
11801180
for the ray:
11811181

1182-
![Figure 8-2](../images/fig-1-08-2.jpg)
1182+
![Figure 9-2](../images/fig-1-09-2.jpg)
11831183

11841184
The bigger the sphere, the fuzzier the reflections will be. This suggests adding a fuzziness
11851185
parameter that is just the radius of the sphere (so zero is no perturbation). The catch is that for
@@ -1208,7 +1208,7 @@
12081208

12091209
We can try that out by adding fuzziness 0.3 and 1.0 to the metals:
12101210

1211-
![Image 8-2](../images/img-1-08-2.jpg)
1211+
![Image 9-2](../images/img-1-09-2.jpg)
12121212

12131213

12141214

@@ -1223,7 +1223,7 @@
12231223
there is a refraction ray at all. For this project, I tried to put two glass balls in our scene, and
12241224
I got this (I have not told you how to do this right or wrong yet, but soon!):
12251225

1226-
![Image 9-1](../images/img-1-09-1.jpg)
1226+
![Image 10-1](../images/img-1-10-1.jpg)
12271227

12281228
Is that right? Glass balls look odd in real life. But no, it isn’t right. The world should be
12291229
flipped upside down and no weird black stuff. I just printed out the ray straight through the middle
@@ -1236,7 +1236,7 @@
12361236
Where $n$ and $n'$ are the refractive indices (typically air = 1, glass = 1.3–1.7, diamond = 2.4)
12371237
and the geometry is:
12381238

1239-
![Figure 9-1](../images/fig-1-09-1.jpg)
1239+
![Figure 10-1](../images/fig-1-10-1.jpg)
12401240

12411241
One troublesome practical issue is that when the ray is in the material with the higher refractive
12421242
index, there is no real solution to Snell’s law and thus there is no refraction possible. Here all
@@ -1309,7 +1309,7 @@
13091309

13101310
We get:
13111311

1312-
![Image 9-2](../images/img-1-09-2.jpg)
1312+
![Image 10-2](../images/img-1-10-2.jpg)
13131313

13141314
(The reader Becker has pointed out that when there is a reflection ray the function returns `false`
13151315
so there are no reflections. He is right, and that is why there are none in the image above. I
@@ -1391,7 +1391,7 @@
13911391

13921392
This gives:
13931393

1394-
![Image 9-3](../images/img-1-09-3.jpg)
1394+
![Image 10-3](../images/img-1-10-3.jpg)
13951395

13961396

13971397

@@ -1407,7 +1407,7 @@
14071407
I first keep the rays coming from the origin and heading to the $z = -1$ plane. We could make it the
14081408
$z = -2$ plane, or whatever, as long as we made $h$ a ratio to that distance. Here is our setup:
14091409

1410-
![Figure 10-1](../images/fig-1-10-1.jpg)
1410+
![Figure 11-1](../images/fig-1-11-1.jpg)
14111411

14121412
This implies $h = tan(\theta/2)$. Our camera now becomes:
14131413

@@ -1452,7 +1452,7 @@
14521452

14531453
gives:
14541454

1455-
![Image 10-1](../images/img-1-10-1.jpg)
1455+
![Image 11-1](../images/img-1-11-1.jpg)
14561456

14571457
To get an arbitrary viewpoint, let’s first name the points we care about. We’ll call the position
14581458
where we place the camera _lookfrom_, and the point we look at _lookat_. (Later, if you want, you
@@ -1464,13 +1464,13 @@
14641464
vector for the camera. Notice we already we already have a plane that the up vector should be in,
14651465
the plane orthogonal to the view direction.
14661466

1467-
![Figure 10-2](../images/fig-1-10-2.jpg)
1467+
![Figure 11-2](../images/fig-1-11-2.jpg)
14681468

14691469
We can actually use any up vector we want, and simply project it onto this plane to get an up vector
14701470
for the camera. I use the common convention of naming a “view up” (_vup_) vector. A couple of cross
14711471
products, and we now have a complete orthonormal basis (u,v,w) to describe our camera’s orientation.
14721472

1473-
![Figure 10-3](../images/fig-1-10-3.jpg)
1473+
![Figure 11-3](../images/fig-1-11-3.jpg)
14741474

14751475
Remember that `vup`, `v`, and `w` are all in the same plane. Note that, like before when our fixed
14761476
camera faced -Z, our arbitrary view camera faces -w. And keep in mind that we can -- but we don’t
@@ -1520,11 +1520,11 @@
15201520

15211521
to get:
15221522

1523-
![Image 10-2](../images/img-1-10-2.jpg)
1523+
![Image 11-2](../images/img-1-11-2.jpg)
15241524

15251525
And we can change field of view to get:
15261526

1527-
![Image 10-3](../images/img-1-10-3.jpg)
1527+
![Image 11-3](../images/img-1-11-3.jpg)
15281528

15291529

15301530

@@ -1549,14 +1549,14 @@
15491549
computed (the image is projected upside down on the film). Graphics people usually use a thin lens
15501550
approximation.
15511551

1552-
![Figure 11-1](../images/fig-1-11-1.jpg)
1552+
![Figure 12-1](../images/fig-1-12-1.jpg)
15531553

15541554
We also don’t need to simulate any of the inside of the camera. For the purposes of rendering an
15551555
image outside the camera, that would be unnecessary complexity. Instead I usually start rays from
15561556
the surface of the lens, and send them toward a virtual film plane, by finding the projection of the
15571557
film on the plane that is in focus (at the distance `focus_dist`).
15581558

1559-
![Figure 11-2](../images/fig-1-11-2.jpg)
1559+
![Figure 12-2](../images/fig-1-12-2.jpg)
15601560

15611561
For that we just need to have the ray origins be on a disk around `lookfrom` rather than from a
15621562
point:
@@ -1628,7 +1628,7 @@
16281628

16291629
We get:
16301630

1631-
![Image 11-1](../images/img-1-11-1.jpg)
1631+
![Image 12-1](../images/img-1-12-1.jpg)
16321632

16331633

16341634

@@ -1680,7 +1680,7 @@
16801680

16811681
This gives:
16821682

1683-
![Image 12-1](../images/img-1-12-1.jpg)
1683+
![Image 13-1](../images/img-1-13-1.jpg)
16841684

16851685
An interesting thing you might note is the glass balls don’t really have shadows which makes them
16861686
look like they are floating. This is not a bug (you don’t see glass balls much in real life, where

0 commit comments

Comments
 (0)