I'm trying to understand BRDF importance sampling following the exemples of the lambertian/diffuse model and the reciprocal Phong model.

I would like to be able to extend the principle to other models. If you know good ressources on the subject please feel free to give me references.

1) In the diffuse case, the pdf $p_d(\theta,\phi)$ of directions is : \begin{equation} p_d(\theta,\phi)=\frac{f_r\cos{\theta}\sin{\theta}}{\int_0^{2\pi}\int_0^{\frac{\pi}{2}} f_r\cos{\theta}\sin{\theta}\,\mathrm{d}\theta\mathrm{d}\phi} =\frac{\cos{\theta}\sin{\theta}}{\pi} \end{equation}

In the reciprocal Phong model the pdf $p_s(\theta_s,\phi_s)$ is :

\begin{equation} p_s(\theta_s,\phi_s)=\frac{k_s\cos^n{\theta_s}\sin{\theta_s}}{\int_0^{2\pi}\int_0^{\frac{\pi}{2}}k_s\cos^n{\theta_s}\sin{\theta_s}\,\mathrm{d}\theta_s\mathrm{d}\phi_s} =\frac{n+1}{2\pi}\cos^n{\theta_s}\sin{\theta_s} \end{equation}

But it seems that people use the densities : \begin{equation} p_d(\theta,\phi)=\frac{\cos{\theta}}{\pi} \end{equation} and \begin{equation} p_s(\theta_s,\phi_s)=\frac{n+1}{2\pi}\cos^n{\theta_s} \end{equation}

What is the reason ? Could we use both versions ? Are they equivalent ?

2) Furthermore : \begin{equation} \int_0^{2\pi}\int_0^{\frac{\pi}{2}} \frac{\cos{\theta}}{\pi}\,\mathrm{d}\theta\mathrm{d}\phi=2\pi\neq 1 \end{equation} and \begin{equation} \int_0^{2\pi}\int_0^{\frac{\pi}{2}}\frac{n+1}{2\pi}\cos^n{\theta_s}\,\mathrm{d}\theta_s\mathrm{d}\phi_s = \quad? \end{equation}

Shouldn't the pdfs have an integral equal to 1?

3) In another post (Probability density function while using spherical coordinates), people explains that the sines functions are never taken into account because they are "artefacts" of the coordinate system.

Is that true ? Should we always reject sines functions ? And if so, why do we compute pdf with sines and reject them after ?


Thanks to the comment of @lightxbulb, it seems that the integrals of my second point should be evaluated with respect to solid angles: \begin{equation} \int_{\Omega} \frac{\cos{\theta}}{\pi}\,\mathrm{d}\omega =\int_0^{2\pi}\int_0^{\frac{\pi}{2}} \frac{\cos{\theta}\sin{\theta}}{\pi}\,\mathrm{d}\theta\mathrm{d}\phi =1 \end{equation} and \begin{equation} \int_{\Omega}\frac{n+1}{2\pi}\cos^n{\theta_s}\,\mathrm{d}\omega =\int_0^{2\pi}\int_0^{\frac{\pi}{2}}\frac{n+1}{2\pi}\cos^n{\theta_s}\sin{\theta_s}\,\mathrm{d}\theta_s\mathrm{d}\phi_s =1 \end{equation}

which brings me to another point:

4) Here are different Monte-Carlo estimators for the reflected part of the rendering equation, with respect to different coordinate system:

Solid angles: \begin{equation} L_r(\vec{x},\vec{\omega}_o)=\frac{1}{N}\sum_{i=1}^N \frac{L_i(\vec{x},\vec{\omega}_i(x,y,z)) f_r(\vec{x},\vec{\omega}_i(x,y,z),\vec{\omega}_o) \cos{\theta}}{p_1(\vec{\omega}_i(x,y,z))} \end{equation} Spherical coordinates: \begin{equation} L_r(\vec{x},\vec{\omega}_o)=\frac{1}{N}\sum_{i=1}^N \frac{L_i(\vec{x},\vec{\omega}_i(\theta,\phi)) f_r(\vec{x},\vec{\omega}_i(\theta,\phi),\vec{\omega}_o) \cos{\theta}\sin{\theta}}{p_2(\vec{\omega}_i(\theta,\phi))} \end{equation} Unit square: \begin{equation} L_r(\vec{x},\vec{\omega}_o)=\frac{\pi}{N}\sum_{i=1}^N \frac{L_i(\vec{x},\vec{\omega}_i(u,v)) f_r(\vec{x},\vec{\omega}_i(u,v),\vec{\omega}_o)}{p_3(\vec{\omega}_i(u,v))} \end{equation}

Sorry for the heavy notations but I would like to fully understand. So: \begin{equation} p_1(\vec{\omega_i})=\frac{\cos{\theta}}{\pi}\quad ? \end{equation}

\begin{equation} p_2(\vec{\omega_i})=\frac{\cos{\theta}\sin{\theta}}{\pi}\quad ? \end{equation}

\begin{equation} p_3(\vec{\omega_i})=\quad ? \end{equation}

People seem to use: \begin{equation} p_3(\vec{\omega_i})=\frac{\cos{\theta}}{\pi} \end{equation}

I'm doing something wrong but I don't know what


The equation involving ($\xi_1,\xi_2$) on page 9 in the reference is not the reflected part of the rendering equation but the integral of the BRDF on the hemisphere. But we don't care here because 1) the luminance $L_i$ in the reflected part is not known (that's why we use importance sampling only on the BRDF) and 2) a Monte-Carlo estimator is something like: \begin{equation} \int f(x)\, \mathrm{d}x\approx\frac{1}{N}\sum_{i=1}^N \frac{f(x_i)}{p(x_i)} \end{equation} So that's just different integrands but the pdfs should be the same. Correct me if I'm wrong.

Here are the mappings:

From the spherical coordinates to solid angles: \begin{equation} \begin{cases} x = \sin{\theta}\cos{\phi} \\ y = \sin{\theta}\sin{\phi} \\ z = \cos{\theta} \end{cases} \end{equation}

From the unit square to the spherical coordinates: \begin{equation} \begin{cases} \theta = \arcsin{\sqrt{u}} \\ \phi = 2\pi v \end{cases} \end{equation}

I suppose that the expression "cosine weighted mapping" comes from the cosine with the normal ($z=\cos{\theta}$) ? If the cosine of the mapping modify the pdf why the sine of the Jacobian doesn't ? And if the mapping modify the pdf why ($\theta = \arcsin{\sqrt{u}}$) doesn't too ?

I have an implementation in front of me (ref : Lászlo Szirmay-Kalos, Monte Carlo Methods in Global Illumination, page 104 and 112). I think that what is done is to use the first estimator with the pdf $p(\vec{\omega}_i)=\frac{\cos{\theta}}{\pi}$. But the choice of the pdf is not explained and I'm very confused with the different mappings and the influence of each transformation on the mathematical formulation of the problem.

  • 2
    $\begingroup$ 1) The versions without the sine are with respect to the solid angle measure, the sine pops out when you go to spherical coordinates from the Jacobian. Either way, the sine gets canceled with the sine from the rendering equation always. 2) You're missing the sine since you plugged in the pdfs with respect to the solid angle measure into an integral over spherical coordinates. 3) The sine comes from the parametrisation. It gets canceled in the estimator by the pdf. $\endgroup$
    – lightxbulb
    Apr 14, 2020 at 19:32
  • $\begingroup$ Thanks for your answer @lightxbulb. If I understand correctly : whatever change of variable we do : from directions (solid angle) to spherical coordinates and from the hemisphere (spherical coordinates) to the unit square (to uniformly pick random numbers), because what we do is selecting a new direction (for reflection), the pdf stay in the "directions/solid angle" coordinate system ? $\endgroup$
    – kipgon
    Apr 14, 2020 at 20:01
  • 1
    $\begingroup$ You always go to spherical coordinates at some point if you use the solid angle formulation. The issue you had comes from the fact that you used a pdf with respect to the solid angle measure as a pdf with respect to spherical coordinates. Note: $d\omega = \sin\theta \,d\theta d\phi$. The sine of the pdf always gets canceled with the sine in the rendering equation in the estimator. $\endgroup$
    – lightxbulb
    Apr 14, 2020 at 20:18
  • $\begingroup$ What is this unit square estimator, why is there a $\pi$, and why is $\cos\theta$ missing from the numerator? $\endgroup$
    – lightxbulb
    Apr 15, 2020 at 18:20
  • $\begingroup$ $\pi$ appeared and $\cos{\theta}\sin{\theta}$ disappeared because of the Jacobian of the mapping from the square to the spherical coordinates. See Lafortune : Using the Modified Phong Reflectance Model for Physically Based Rendering, page 9). $\endgroup$
    – kipgon
    Apr 15, 2020 at 18:31


Your Answer

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