Skip to content

Commit 58bdb04

Browse files
committed
Fix line lengths in Book3
1 parent 114f42b commit 58bdb04

File tree

1 file changed

+34
-30
lines changed

1 file changed

+34
-30
lines changed

books/RayTracingTheRestOfYourLife.html

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1340,14 +1340,14 @@
13401340
in the _LMS color space_ (long, medium, short).
13411341

13421342
If the light does scatter, it will have a directional distribution that we can describe as a PDF
1343-
over solid angle. I will refer to this as its _scattering PDF_: $\mathit{pScatter}()$. The scattering PDF
1344-
will vary with the outgoing direction: $\mathit{pScatter}(\omega_o)$. The scattering PDF can also vary with
1345-
_incident direction_: $\mathit{pScatter}(\omega_i, \omega_o)$. You can see this varying with incident
1346-
direction when you look at reflections off a road -- they become mirror-like as your viewing angle
1347-
(incident angle) approaches grazing. Lastly, the scattering PDF can also depend on the scattering
1348-
position: $\mathit{pScatter}(\textbf{x}, \omega_i, \omega_o)$. The $\textbf{x}$ is just a vector representing
1349-
the scattering position: $\textbf{x} = (x, y, z)$. The Albedo of an object can also depend on these
1350-
quantities: $A(\textbf{x}, \omega_i, \omega_o)$.
1343+
over solid angle. I will refer to this as its _scattering PDF_: $\mathit{pScatter}()$. The
1344+
scattering PDF will vary with the outgoing direction: $\mathit{pScatter}(\omega_o)$. The scattering
1345+
PDF can also vary with _incident direction_: $\mathit{pScatter}(\omega_i, \omega_o)$. You can see
1346+
this varying with incident direction when you look at reflections off a road -- they become
1347+
mirror-like as your viewing angle (incident angle) approaches grazing. Lastly, the scattering PDF
1348+
can also depend on the scattering position: $\mathit{pScatter}(\textbf{x}, \omega_i, \omega_o)$. The
1349+
$\textbf{x}$ is just a vector representing the scattering position: $\textbf{x} = (x, y, z)$. The
1350+
Albedo of an object can also depend on these quantities: $A(\textbf{x}, \omega_i, \omega_o)$.
13511351

13521352
<div class='together'>
13531353
The color of a surface is found by integrating these terms over the unit hemisphere by the incident
@@ -1363,8 +1363,8 @@
13631363
that is shining on that point. This is a recursive algorithm, and is the reason our `ray_color`
13641364
function returns the color of the current object multiplied by the color of the next ray.
13651365

1366-
Note that $A()$, $\mathit{pScatter}()$, and $\text{Color}_i()$ may all depend on the wavelength of the light,
1367-
$\lambda$, but I've left it out of the equation because it's complicated enough as it is.
1366+
Note that $A()$, $\mathit{pScatter}()$, and $\text{Color}_i()$ may all depend on the wavelength of
1367+
the light, $\lambda$, but I've left it out of the equation because it's complicated enough as it is.
13681368
</div>
13691369

13701370

@@ -1385,9 +1385,9 @@
13851385
For a Lambertian surface we already implicitly implemented this formula for the special case where
13861386
$p()$ is a cosine density. The $\mathit{pScatter}()$ of a Lambertian surface is proportional to
13871387
$\cos(\theta_o)$, where $\theta_o$ is the angle relative to the surface normal. All two dimensional
1388-
PDFs need to integrate to one over the whole surface (remember that $\mathit{pScatter}()$ is a PDF). We set
1389-
$\mathit{pScatter}(\theta_o < 0) = 0$ so that we don't scatter below the horizon. The integral of
1390-
$\cos(\theta_o)$ over the hemisphere is $\pi$.
1388+
PDFs need to integrate to one over the whole surface (remember that $\mathit{pScatter}()$ is a
1389+
PDF). We set $\mathit{pScatter}(\theta_o < 0) = 0$ so that we don't scatter below the horizon. The
1390+
integral of $\cos(\theta_o)$ over the hemisphere is $\pi$.
13911391

13921392
<div class='together'>
13931393
To integrate over the hemisphere, remember that in spherical coordinates:
@@ -1446,27 +1446,29 @@
14461446
<div class='together'>
14471447
Our goal over the next two chapters is to instrument our program to send a bunch of extra rays
14481448
toward light sources so that our picture is less noisy. Let’s assume we can send a bunch of rays
1449-
toward the light source using a PDF $\mathit{pLight}(\omega_o)$. Let’s also assume we have a PDF related to
1450-
$\mathit{pScatter}$, and let’s call that $\mathit{pSurface}(\omega_o)$. A great thing about PDFs is that you can just
1451-
use linear mixtures of them to form mixture densities that are also PDFs. For example, the simplest
1452-
would be:
1449+
toward the light source using a PDF $\mathit{pLight}(\omega_o)$. Let’s also assume we have a PDF
1450+
related to $\mathit{pScatter}$, and let’s call that $\mathit{pSurface}(\omega_o)$. A great thing
1451+
about PDFs is that you can just use linear mixtures of them to form mixture densities that are also
1452+
PDFs. For example, the simplest would be:
14531453

1454-
$$ p(\omega_o) = \frac{1}{2} \mathit{pSurface}(\omega_o) + \frac{1}{2} \mathit{pLight}(\omega_o)$$
1454+
$$ p(\omega_o) = \frac{1}{2} \mathit{pSurface}(\omega_o) + \frac{1}{2}
1455+
\mathit{pLight}(\omega_o)$$
14551456
</div>
14561457

14571458
As long as the weights are positive and add up to one, any such mixture of PDFs is a PDF. Remember,
14581459
we can use any PDF: _all PDFs eventually converge to the correct answer_. So, the game is to figure
14591460
out how to make the PDF larger where the product
14601461

1461-
$$ \mathit{pScatter}(\textbf{x}, \omega_i, \omega_o) \cdot \text{Color}_i(\textbf{x}, \omega_i) $$
1462+
$$ \mathit{pScatter}(\textbf{x}, \omega_i, \omega_o) \cdot
1463+
\text{Color}_i(\textbf{x}, \omega_i) $$
14621464

14631465
is largest. For diffuse surfaces, this is mainly a matter of guessing where
14641466
$\text{Color}_i(\textbf{x}, \omega_i)$ is largest. Which is equivalent to guessing where the most
14651467
light is coming from.
14661468

1467-
For a mirror, $\mathit{pScatter}()$ is huge only near one direction, so $\mathit{pScatter}()$ matters a lot more. In
1468-
fact, most renderers just make mirrors a special case, and make the $\mathit{pScatter}()/p()$ implicit -- our
1469-
code currently does that.
1469+
For a mirror, $\mathit{pScatter}()$ is huge only near one direction, so $\mathit{pScatter}()$
1470+
matters a lot more. In fact, most renderers just make mirrors a special case, and make the
1471+
$\mathit{pScatter}()/p()$ implicit -- our code currently does that.
14701472

14711473

14721474
Returning to the Cornell Box
@@ -2416,9 +2418,10 @@
24162418
</div>
24172419

24182420
<div class='together'>
2419-
The details of how this is done under the hood varies for $\mathit{pSurface}$ and $\mathit{pLight}$, but that is
2420-
exactly what class hierarchies were invented for! It’s never obvious what goes in an abstract class,
2421-
so my approach is to be greedy and hope a minimal interface works, and for `pdf` this implies:
2421+
The details of how this is done under the hood varies for $\mathit{pSurface}$ and $\mathit{pLight}$,
2422+
but that is exactly what class hierarchies were invented for! It’s never obvious what goes in an
2423+
abstract class, so my approach is to be greedy and hope a minimal interface works, and for `pdf`
2424+
this implies:
24222425

24232426
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
24242427
#ifndef PDF_H
@@ -2741,7 +2744,8 @@
27412744

27422745
For example, we could just average the two densities:
27432746

2744-
$$ \mathit{pMixture}(\omega_o) = \frac{1}{2} \mathit{pSurface}(\omega_o) + \frac{1}{2} \mathit{pLight}(\omega_o)$$
2747+
$$ \mathit{pMixture}(\omega_o) = \frac{1}{2} \mathit{pSurface}(\omega_o) + \frac{1}{2}
2748+
\mathit{pLight}(\omega_o)$$
27452749

27462750
<div class='together'>
27472751
How would we instrument our code to do that? There is a very important detail that makes this not
@@ -2769,10 +2773,10 @@
27692773
correct, we would have to solve backwards to figure which PDF the direction could come from. Which
27702774
honestly sounds like a nightmare, but fortunately we don't need to do that. There are some
27712775
directions that both PDFs could have generated. For example, a direction toward the light could have
2772-
been generated by either $\mathit{pLight}$ _or_ $\mathit{pSurface}$. It is sufficient for us to solve for the pdf
2773-
value of $\mathit{pSurface}$ and of $\mathit{pLight}$ for a random direction and then take the PDF mixture weights to
2774-
solve for the total PDF value for that direction. The mixture density class is actually pretty
2775-
straightforward:
2776+
been generated by either $\mathit{pLight}$ _or_ $\mathit{pSurface}$. It is sufficient for us to
2777+
solve for the pdf value of $\mathit{pSurface}$ and of $\mathit{pLight}$ for a random direction and
2778+
then take the PDF mixture weights to solve for the total PDF value for that direction. The mixture
2779+
density class is actually pretty straightforward:
27762780

27772781
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
27782782
class mixture_pdf : public pdf {

0 commit comments

Comments
 (0)