# Transforming between solid angle and spherical angle distribution in PBRT

In the Monte Carlo chapter of PBRT, in the section Transforming Between Distributions, they say "The density with respect to $$\theta$$ and $$\phi$$ can therefore be derived", but they start with

\begin{align} p(\theta, \phi) \ d\theta \ d\phi = p(\omega) \ d\omega \end{align}

and my question is, how to see that this is true? I get how, if you are ok with that, then substituting $$d\omega = \sin \theta \ d\theta \ d\phi$$ gives the result that follows, but I don't understand how to even read that starting line, like is it saying "the function defined with respect to $$\theta$$ and $$\phi$$ times $$d\theta$$ times $$d\phi$$ is equal to the function defined with respect to $$\omega$$ times $$d\omega$$"?

Anyway, it seems like it should instead be

\begin{align} p(\omega) \ d\omega = p(\theta, \phi) \sin \theta \ d\theta \ d\phi \end{align}

according to section 5.5? (Express function in terms of $$\theta$$ and $$\phi$$ and use $$d\omega = \sin \theta \ d\theta \ d\phi$$.)

• It is two functions. One is defined wrt $d\omega$, let's call it $p_{\omega}$ and the other wrt $d\phi d\theta$ let's call it $p_{s}$. Then by equating the expressions you get the relationship. Sep 18, 2022 at 21:10
• What is $p(\omega) d\omega$ by itself though? I've never seen a function written this way, like we're not integrating it or anything, we're just writing $p(\omega) d\omega$. What does that even mean? This just seems like an abuse of the notation or something. Sep 19, 2022 at 2:02
• I found someone else confused about the EXACT same issue, so thankfully it's not just me, but sadly, there is no clear answer there: computergraphics.stackexchange.com/questions/5267/… The poster there says: In the book, to find p(θ,ϕ) they state that p(θ,ϕ)dθdϕ=p(ω)dω, but why? He actually repeats his question multiple times, and while good info is provided, that question doesn't ever seem to get answered. I've also seen other resources, such as scratchapixel, just use that equality exactly as in the PBRT book, so no help there... Sep 19, 2022 at 3:40
• $p(\omega)d\omega$ is a differential form, it is not abuse of notation. Essentially you want to find the expression of a probability density with respect to different measures. By definition a probability density function $f$ must be non-negative and integrate to $1$. Now assume you are given a pdf $f$ wrt the solid angle measure. Then you know that $\int_{\Omega}f(\omega)d\omega=1$. Now using $d\omega = |\sin\theta|d\theta d\phi$ you get $\int_{0}^{2\pi}\int_{0}^{\pi/2}f(\omega)|\sin\theta|d\theta d\phi=1$. So a function proportional to $f$ that integtates to $1$ is $g = f |\sin\theta|$. Sep 19, 2022 at 9:41
• $\omega$ is just notation for a unit vector. E.g. you can define it using $\theta$ and $\phi$ as $\omega = R(\sin\theta\cos\phi, \sin\theta\sin\phi, \cos\theta)$, where $R$ is a rotation matrix that orients this to match the upper hemisphere at the intersection point. Here $d\omega$ refers to the surface measure on the unit sphere, typically it is expanded wrt spherical coordinates as $|\sin\theta|d\theta d\phi$, however you could also express it wrt Cartesian coords as $\delta(\|(x,y,z)\|-1)dx dy dz$, so the $\omega$ part is used to remain agnostic (discussed somewhere in Veach's thesis). Sep 19, 2022 at 16:27

## 1 Answer

As lightxbulb mentioned in the comments, one confusing thing here is that two different functions are being called $$p$$. Kind of like function overloading in C++, the $$p(\omega)$$ and $$p(\theta, \phi)$$ are two different functions, in the sense of having different domains and different dependence on their inputs, though in some sense they abstractly represent the same distribution.

The other thing that's confusing here is that the values returned by these functions are not just numbers. Since these are probability density functions, their values carry units of inverse area. Moreover, the two functions are expressing density with respect to different areas: $$p(\omega)$$ is probability per area on the unit sphere, while $$p(\theta, \phi)$$ is probability per unit area on the $$\theta$$-$$\phi$$ plane—an abstract 2D plane formed by $$\theta$$ and $$\phi$$ as Cartesian coordinates (just like the $$x$$-$$y$$ plane). These area measures are related to each other, but not the same: as you observed, $$d\omega = \sin \theta \, d\theta \, d\phi$$.

Notation like $$d\omega$$ and $$d\theta \, d\phi$$ refers to these area measures. As mentioned in the comments, this can be mathematically formalized as differential forms (here's an introduction I found useful).

Because $$p(\omega)$$ is a probability density per area on the unit sphere, if $$d\omega$$ is a "small" area on the unit sphere around the point $$\omega$$, then $$p(\omega) \, d\omega$$ works out to be a probability—not a density, but just a plain old probability number. In the limit of $$d\omega$$ being infinitesimal, $$p(\omega) \, d\omega$$ is the amount of probability enclosed within the area $$d\omega$$.

Similarly $$p(\theta, \phi) \, d\theta \, d\phi$$ is the amount of probability enclosed within a "small" area of the $$\theta$$-$$\phi$$ plane. The statement that $$p(\omega) \, d\omega = p(\theta, \phi) \, d\theta \, d\phi$$ is intended to mean the following: the amount of probability in a small area of the unit sphere is equal to the amount of probability in the corresponding small area of the $$\theta$$-$$\phi$$ plane. In other words, probability is conserved by mapping between these two domains. This is the condition that makes these two functions represent "the same" distribution, abstractly, despite being parameterized with different variables.

The condition needs to be written that way because the probability densities aren't unitless numbers. If we had some function whose values were just plain numbers without units attached, and we wanted to reparameterize it with different variables, the condition would just be that $$f(\omega) = f(\theta, \phi)$$: the function should keep the same value at "the same" point when we change variables. But with the probability densities, we don't want the same value of the function, we want the same amount of probability in each part of the domain.

Using this "conservation of probability" condition $$p(\omega) \, d\omega = p(\theta, \phi) \, d\theta \, d\phi$$ together with the relationship between the two area measures, $$d\omega = \sin \theta \, d\theta \, d\phi$$, we can derive: $$p(\theta, \phi) = p(\omega) \, \sin \theta$$ which shows that to express the a spherical distribution in terms of $$\theta, \phi$$, you have to not only change variables but also multiply the function by $$\sin \theta$$ to conserve the probability. That $$\sin \theta$$ factor is known as the "inverse Jacobian", and it accounts for how the transformation stretches the area in different parts of the domain.

• This makes things so much clearer! I definitely was not seeing $p(\theta, \phi)$ in a Cartesian plane prior to this, and also now I understand why units for the density function must be (in this case) inverse area, because multiplying them by little areas cancels, to yield unitless probabilities. Super helpful! Sep 26, 2022 at 22:46