If in the path tracing use case, I have some sampling strategies to sample a scattering direction in a 2D space ($\theta, \phi$). Of course, I need to convert it to a 3D direction vector (with length being 1). My question is, is the PDF of this 3D direction vector the same as that of $(\theta, \phi)$? If I recall correctly, there should be a Jacobian term for the conversion from spherical coords to 3D Cartesian space, so the PDF is probably different?

If the sampling PDF for $\theta$ is $p_1(\theta), \theta \in [0, \pi)$ (volumetric scattering requires sampling on the entire sphere), and PDF for sampling $\phi$ is $p_2(\phi), \phi \in [0, 2\pi)$.

  • What will be the PDF of the 3D direction vector $p_d(\omega)$?
  • What about the case that $\theta, \phi$ is sampled from a 2D joint distribution $p(\theta, \phi)$ (like, sampling from precomputed tabulations), is there any difference from the first case?
  • And if I am gonna evaluate the MC integral here, is the following correct? $$ \text{scattering throughput}=f(\omega, \omega') \times C / p_d(\omega), C=\begin{cases} \sigma_s, \text{volumetric}\\ \omega^T \omega',\text{surface} \end{cases} $$

1 Answer 1


If your map $\omega:[0,2\pi) \times [0,\pi] \to \mathbb{S}^2\subset \mathbb{R}^3$ is the standard spherical coordinates map:

$$\omega = (\cos\phi \sin\theta, \sin\phi \sin\theta, \cos\theta),$$

then the Jacobian is:

$$J = \frac{\partial \omega}{\partial (\phi, \theta)} = \begin{bmatrix} \uparrow & \uparrow \\\frac{\partial\omega}{\partial \phi} & \frac{\partial\omega} {\partial\theta} \\ \downarrow & \downarrow \end{bmatrix} = \begin{bmatrix} -\sin\phi \sin\theta & \cos\phi\cos\theta \\ \cos\phi\sin\theta & \sin\phi \cos\theta \\ 0 & \sin\theta\end{bmatrix}.$$

The area measure on the sphere is $d\sigma(\omega) = \sqrt{\det J^T J} \,d\lambda(\phi)d\lambda(\theta) = |\sin\theta|\,d\lambda(\phi)d\lambda(\theta)$. Here $\lambda$ is just the Lebesgue measure and it is often omitted. Now assume the probability density function for picking $(\phi,\theta)$ is $p_{\phi,\theta}$. Taking into account $d\sigma(\omega) = |\sin\theta|\,d\lambda(\phi)d\lambda(\theta)$ we have: $$p_{\phi,\theta}(\phi,\theta) \,d\lambda(\phi) d\lambda(\theta) = p_{\sigma}(\omega)\,d\sigma(\omega) \implies p_{\sigma}(\omega) = \frac{p_{\phi,\theta}(\phi,\theta)}{|\sin\theta|}.$$

Note that translations and rotations do not change the term $\sqrt{J^T J}$ since the derivative of a translation is zero, and a rotation is orthogonal $R^TR=I$ and thus $\sqrt{J^TR^TRJ} = \sqrt{J^TJ} = |\sin\theta|$. I am mentioning this since typically you integrate over the sphere not w.r.t. the standard coordinate axes, but some frame oriented around the normal, which can be implemented as $\omega' = R\omega$.

If $p_{\phi,\theta}$ is separable you can write it as $p_{\phi,\theta}(\phi,\theta) = p_{\phi}(\phi)p_{\theta}(\theta)$.

The change of variables in an integral over the unit sphere happens as follows:

\begin{align} I &=\int_{\mathbb{S}^2} L_i(x, \omega_i) f(\omega_o, x, \omega_i) (\omega_i \cdot n)\,d\sigma(\omega_i) \\ &= \int_{0}^{2\pi}\int_0^{\pi} L_i(x,\omega_i(\phi,\theta))f(\omega_o,x, \omega_i(\phi,\theta)) (\omega_i(\phi,\theta) \cdot n)|\sin\theta|\,d\lambda(\theta) d\lambda(\phi) \\ &= \int_0^1\int_0^1 L_i(x,\omega_i(u,v))f(\omega_o,x, \omega_i(u,v)) (\omega_i(u,v) \cdot n)\underbrace{|\sin\theta|\left|\det \frac{\partial(\phi,\theta)}{\partial (u,v)}\right|}_{1/p_{\sigma}(\omega_i)}\,d\lambda(u) d\lambda(v) \\ &= \int_0^1\int_0^1 \frac{L_i(x,\omega_i(u_j,v_j))f(\omega_o,x, \omega_i(u,v)) (\omega_i(u,v) \cdot n)}{p_{\sigma}(\omega_i(u,v))}\,d\lambda(u) d\lambda(v) \\ &\approx \frac{1}{N} \sum_{j=1}^N\frac{L_i(x,\omega_i(u_j,v_j))f(\omega_o,x, \omega_i(u_j,v_j)) (\omega_i(u_j,v_j) \cdot n)}{p_{\sigma}(\omega_i(u_j,v_j))}, \quad (u_j,v_j) \sim U[0,1]^2. \end{align}

  • $\begingroup$ Thank you for your comprehensive answer! $\endgroup$ Mar 16 at 2:13
  • 1
    $\begingroup$ @Enigmatisms I added in that translations and rotations would not change this, this means you can for example choose $\theta$ to be the angle to the normal. $\endgroup$
    – lightxbulb
    Mar 16 at 10:35
  • $\begingroup$ Thanks for the tip $\endgroup$ Mar 17 at 6:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.