Skip to content

Commit 114f42b

Browse files
committed
Change \textit to \mathit
1 parent c4bdaa9 commit 114f42b

File tree

1 file changed

+32
-32
lines changed

1 file changed

+32
-32
lines changed

books/RayTracingTheRestOfYourLife.html

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@
388388
Our Buffon Needle example is a way of calculating $\pi$ by solving for the ratio of the area of the
389389
circle and the area of the inscribing square:
390390

391-
$$ \frac{\text{area}(\textit{circle})}{\text{area}(\textit{square})} = \frac{\pi}{4} $$
391+
$$ \frac{\text{area}(\mathit{circle})}{\text{area}(\mathit{square})} = \frac{\pi}{4} $$
392392

393393
We picked a bunch of random points in the inscribing square and counted the fraction of them that
394394
were also in the unit circle. This fraction was an estimate that tended toward $\frac{\pi}{4}$ as
@@ -397,14 +397,14 @@
397397
$\frac{\pi}{4}$, and we know that the area of a inscribing square is $4r^2$, so we could then use
398398
those two quanties to get the area of a circle:
399399

400-
$$ \frac{\text{area}(\textit{circle})}{\text{area}(\textit{square})} = \frac{\pi}{4} $$
401-
$$ \frac{\text{area}(\textit{circle})}{(2r)^2} = \frac{\pi}{4} $$
402-
$$ \text{area}(\textit{circle}) = \frac{\pi}{4} 4r^2 $$
403-
$$ \text{area}(\textit{circle}) = \pi r^2 $$
400+
$$ \frac{\text{area}(\mathit{circle})}{\text{area}(\mathit{square})} = \frac{\pi}{4} $$
401+
$$ \frac{\text{area}(\mathit{circle})}{(2r)^2} = \frac{\pi}{4} $$
402+
$$ \text{area}(\mathit{circle}) = \frac{\pi}{4} 4r^2 $$
403+
$$ \text{area}(\mathit{circle}) = \pi r^2 $$
404404

405405
We choose a circle with radius $r = 1$ and get:
406406

407-
$$ \text{area}(\textit{circle}) = \pi $$
407+
$$ \text{area}(\mathit{circle}) = \pi $$
408408

409409
Our work above is equally valid as a means to solve for $pi$ as it is a means to solve for the area
410410
of a circle:
@@ -1340,12 +1340,12 @@
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_: $\textit{pScatter}()$. The scattering PDF
1344-
will vary with the outgoing direction: $\textit{pScatter}(\omega_o)$. The scattering PDF can also vary with
1345-
_incident direction_: $\textit{pScatter}(\omega_i, \omega_o)$. You can see this varying with incident
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
13461346
direction when you look at reflections off a road -- they become mirror-like as your viewing angle
13471347
(incident angle) approaches grazing. Lastly, the scattering PDF can also depend on the scattering
1348-
position: $\textit{pScatter}(\textbf{x}, \omega_i, \omega_o)$. The $\textbf{x}$ is just a vector representing
1348+
position: $\mathit{pScatter}(\textbf{x}, \omega_i, \omega_o)$. The $\textbf{x}$ is just a vector representing
13491349
the scattering position: $\textbf{x} = (x, y, z)$. The Albedo of an object can also depend on these
13501350
quantities: $A(\textbf{x}, \omega_i, \omega_o)$.
13511351

@@ -1355,15 +1355,15 @@
13551355

13561356
$$ \text{Color}_o(\textbf{x}, \omega_o) = \int_{\omega_i}
13571357
A(\textbf{x}, \omega_i, \omega_o) \cdot
1358-
\textit{pScatter}(\textbf{x}, \omega_i, \omega_o) \cdot
1358+
\mathit{pScatter}(\textbf{x}, \omega_i, \omega_o) \cdot
13591359
\text{Color}_i(\textbf{x}, \omega_i) $$
13601360

13611361
We've added a $\text{Color}_i$ term. The scattering PDF and the albedo at the surface of an object
13621362
are acting as filters to the light that is shining on that point. So we need to solve for the light
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()$, $\textit{pScatter}()$, and $\text{Color}_i()$ may all depend on the wavelength of the light,
1366+
Note that $A()$, $\mathit{pScatter}()$, and $\text{Color}_i()$ may all depend on the wavelength of the light,
13671367
$\lambda$, but I've left it out of the equation because it's complicated enough as it is.
13681368
</div>
13691369

@@ -1374,7 +1374,7 @@
13741374
If we apply the Monte Carlo basic formula we get the following statistical estimate:
13751375

13761376
$$ \text{Color}_o = \frac{A(\textbf{x}, \omega_i, \omega_o) \cdot
1377-
\textit{pScatter}(\textbf{x}, \omega_i, \omega_o) \cdot
1377+
\mathit{pScatter}(\textbf{x}, \omega_i, \omega_o) \cdot
13781378
\text{Color}_i(\textbf{x}, \omega_i)}
13791379
{p(\textbf{x}, \omega_o)} $$
13801380

@@ -1383,10 +1383,10 @@
13831383
</div>
13841384

13851385
For a Lambertian surface we already implicitly implemented this formula for the special case where
1386-
$p()$ is a cosine density. The $\textit{pScatter}()$ of a Lambertian surface is proportional to
1386+
$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 $\textit{pScatter}()$ is a PDF). We set
1389-
$\textit{pScatter}(\theta_o < 0) = 0$ so that we don't scatter below the horizon. The integral of
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
13901390
$\cos(\theta_o)$ over the hemisphere is $\pi$.
13911391

13921392
<div class='together'>
@@ -1404,13 +1404,13 @@
14041404
If we have a scattering PDF that is $\cos(\theta_o)$ over the hemisphere, then we need to normalize
14051405
by $\pi$. So for a Lambertian surface the scattering PDF is:
14061406

1407-
$$ \textit{pScatter}(\omega_o) = \frac{\cos(\theta_o)}{\pi} $$
1407+
$$ \mathit{pScatter}(\omega_o) = \frac{\cos(\theta_o)}{\pi} $$
14081408
</div>
14091409

14101410
<div class='together'>
14111411
We'll assume that the PDF is equal to the scattering PDF:
14121412

1413-
$$ p(\omega_o) = \textit{pScatter}() = \frac{\cos(\theta_o)}{\pi} $$
1413+
$$ p(\omega_o) = \mathit{pScatter}() = \frac{\cos(\theta_o)}{\pi} $$
14141414

14151415
The numerator and denominator cancel out, and we get:
14161416

@@ -1428,7 +1428,7 @@
14281428
_Bidirectional Reflectance Distribution Function_ (BRDF). It relates pretty simply to our terms:
14291429

14301430
$$ BRDF(\omega_i, \omega_o) = \frac{A(\textbf{x}, \omega_i, \omega_o) \cdot
1431-
\textit{pScatter}(\textbf{x}, \omega_i, \omega_o)}{\cos(\theta_o)} $$
1431+
\mathit{pScatter}(\textbf{x}, \omega_i, \omega_o)}{\cos(\theta_o)} $$
14321432

14331433
So for a Lambertian surface for example, $BRDF = A / \pi$. Translation between our terms and BRDF is
14341434
easy. For participating media (volumes), our albedo is usually called the _scattering albedo_, and
@@ -1446,26 +1446,26 @@
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 $\textit{pLight}(\omega_o)$. Let’s also assume we have a PDF related to
1450-
$\textit{pScatter}$, and let’s call that $\textit{pSurface}(\omega_o)$. A great thing about PDFs is that you can just
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
14511451
use linear mixtures of them to form mixture densities that are also PDFs. For example, the simplest
14521452
would be:
14531453

1454-
$$ p(\omega_o) = \frac{1}{2} \textit{pSurface}(\omega_o) + \frac{1}{2} \textit{pLight}(\omega_o)$$
1454+
$$ p(\omega_o) = \frac{1}{2} \mathit{pSurface}(\omega_o) + \frac{1}{2} \mathit{pLight}(\omega_o)$$
14551455
</div>
14561456

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

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

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

1467-
For a mirror, $\textit{pScatter}()$ is huge only near one direction, so $\textit{pScatter}()$ matters a lot more. In
1468-
fact, most renderers just make mirrors a special case, and make the $\textit{pScatter}()/p()$ implicit -- our
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
14691469
code currently does that.
14701470

14711471

@@ -1674,7 +1674,7 @@
16741674
material, but Lambertian requires a $\cos(\theta_o)$ sampling pattern. So any differences that we
16751675
see is because we are using a slightly different material. We're going to uniformly scatter random
16761676
directions from the hemisphere and perfectly match the PDF, given by
1677-
$\textit{pScatter}(\omega_o) = p(\omega_o) = \frac{1}{2\pi}$.
1677+
$\mathit{pScatter}(\omega_o) = p(\omega_o) = \frac{1}{2\pi}$.
16781678

16791679
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
16801680
class lambertian : public material {
@@ -2416,7 +2416,7 @@
24162416
</div>
24172417

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

@@ -2735,13 +2735,13 @@
27352735
mixtures of any PDFs to form mixture densities that are also PDFs. Any weighted average of PDFs is
27362736
also a PDF. As long as the weights are positive and add up to any one, we have a new PDF.
27372737

2738-
$$ \textit{pMixture}() = w_0 p_0() + w_1 p_1() + w_2 p_2() + \ldots + w_{n-1} p_{n-1}() $$
2738+
$$ \mathit{pMixture}() = w_0 p_0() + w_1 p_1() + w_2 p_2() + \ldots + w_{n-1} p_{n-1}() $$
27392739

27402740
$$ 1 = w_0 + w_1 + w_2 + \ldots + w_{n-1} $$
27412741

27422742
For example, we could just average the two densities:
27432743

2744-
$$ \textit{pMixture}(\omega_o) = \frac{1}{2} \textit{pSurface}(\omega_o) + \frac{1}{2} \textit{pLight}(\omega_o)$$
2744+
$$ \mathit{pMixture}(\omega_o) = \frac{1}{2} \mathit{pSurface}(\omega_o) + \frac{1}{2} \mathit{pLight}(\omega_o)$$
27452745

27462746
<div class='together'>
27472747
How would we instrument our code to do that? There is a very important detail that makes this not
@@ -2754,7 +2754,7 @@
27542754
pick direction according to pLight
27552755
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
27562756

2757-
But solving for the PDF value of $\textit{pMixture}$ is slightly more subtle. We can't just
2757+
But solving for the PDF value of $\mathit{pMixture}$ is slightly more subtle. We can't just
27582758

27592759
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
27602760
if (direction is from pSurface)
@@ -2769,8 +2769,8 @@
27692769
correct, we would have to solve backwards to figure which PDF the direction could come from. Which
27702770
honestly sounds like a nightmare, but fortunately we don't need to do that. There are some
27712771
directions that both PDFs could have generated. For example, a direction toward the light could have
2772-
been generated by either $\textit{pLight}$ _or_ $\textit{pSurface}$. It is sufficient for us to solve for the pdf
2773-
value of $\textit{pSurface}$ and of $\textit{pLight}$ for a random direction and then take the PDF mixture weights to
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
27742774
solve for the total PDF value for that direction. The mixture density class is actually pretty
27752775
straightforward:
27762776

0 commit comments

Comments
 (0)