<p>Normally $sin(\theta)$ isn't written as part of the pdf, because it's an artifact from using double integral for spherical integration. The double integral does the integration over a rectangular domain (in you case of size $2\pi$ x $\pi/2$), while you want integration over a sphere/hemisphere, so $sin(\theta)$ is added there as a weight function to transform rectangular to spherical integration.</p>

<p>A common notation is to use integration over solid angle with single integral and differential solid angle $d\omega$ denoting 2D integration over sphere, and you won't see the $sin(\theta)$ term in there.</p>

<p>To clarify, the notation with single integral has constant infinitesimally small solid angle $d\omega$ over the sphere. However, for the double integral over $\theta$ and $\phi$ the solid angle isn't constant (think of <a href="https://en.wikipedia.org/wiki/Sphere#/media/File:Sphere_wireframe_10deg_6r.svg" rel="nofollow noreferrer">sphere tessellation</a>) but a function of $sin(\theta)$. In case of Monte Carlo integration and even distribution of samples over the hemisphere, each sample represents solid angle of $2\pi/N$ steradians and there's no $sin(\theta)$ solid angle weighting required.</p>

CC BY-SA 3.0
2017-12-22T02:44:55.153Z
Yet they are choosing samples from a join pdf of theta and azimuth (as you said, double integral over a rectangle) but the resulting radiance is instead multiplied by 1 / 2pi  instead of sin(theta) / 2pi, why is that?
Row Rebel
CC BY-SA 3.0
2017-12-22T04:06:47.043Z
If you are referring to Monte Carlo integration, there's no weighting required because the samples are evenly distributed over the hemisphere by uniformSampleHemisphere() function, so each sample has the same the same solid angle. In the case of double integral the samples close to sphere poles have smaller solid angle which is compensated with the sin-term
JarkkoL
CC BY-SA 3.0
2017-12-22T04:17:31.323Z
Btw, if you would implement the integration with two nested sums over theta & phi, you would need to add the sin-term because the samples near poles would represent smaller solid angle than the samples at the equator.
JarkkoL
CC BY-SA 3.0
2017-12-22T14:30:35.360Z
So essentially since the integration is a single recursive sum, each  received differential radiance from a pixel represents the radiance along a single steradian and we multiply that by 2pi to estimate the irradiance arriving at point x, to finally multiply that value with the BRDF to see how much of that irradiance arrives to the camera?
Row Rebel
CC BY-SA 3.0
2017-12-22T16:55:41.717Z
For hemispherical integration with even sample distribution (no biasing towards any region), each sample covers 2pi/n sr (hemisphere=2pi sr). So for the rendering equation you just add up all the samples multiplied by the solid angle for each sample (sample=incident radiance * brdf * cos(theta)) to calculate the total radiance from a pixel towards the eye.
JarkkoL
CC BY-SA 3.0
2017-12-21T03:37:31.990Z
2017-12-22T04:51:00.597Z
2017-12-22T04:51:00.597Z
JarkkoL
<p>I'm following <a href="https://www.scratchapixel.com/lessons/3d-basic-rendering/global-illumination-path-tracing/global-illumination-path-tracing-practical-implementation" rel="nofollow noreferrer">this tutorial</a> where at somepoint the derived PDF for spherical coordinates for a Lambertian surface is</p>

<p>\begin{array}{l}
p(\theta, \phi) = \dfrac{\sin \theta}{2 \pi}.
\end{array}</p>

<p>But as soon as they compute a sample, the result is instead divided by $ \dfrac{1}{2\pi} $, which as they say is the "pdf of the integral"</p>

<p>Why isn't it divided by $ \frac{\sin \theta}{2 \pi} $ instead?</p>

<p>If we were using differential steradians over the unit hemisphere, the only possible probability density function integrating to 1 is infact $ \frac{1}{2\pi} $</p>

<p>But if we separate the integral over the hemisphere traced by spherical coordinates</p>

<p>$$ 
\int_{\phi = 0}^{2\pi} \int_{\theta = 0}^{\frac{\pi}{2}}  \,  \frac{\sin{\theta}}{2\pi}d\theta d\phi= 1. 
$$</p>

<p>The PDF now becomes $ \frac{\sin \theta}{2 \pi} $ yet they still divide by $ \frac{1}{2\pi} $</p>

<p>EDIT: after carefully reviewing the concept of PDFs and integration over the hemisphere I'm starting to think the article I've linked is making a substantial error, mixing the idea of importance sampling with the pdf of choosing a direction of reflectance from a lambertian surface</p>

<p>Radiance is defined as
$$ L_{(x,\omega)} = \frac{\mathrm{d}^2\Phi}{\mathrm{d}\omega\ cos\theta\ \mathrm{d}x}  $$
Since it's defined over differential solid angles, we can interpret the result of one sample as if it was the flux density "over a unit steradian"</p>

<p>If we use monte carlo estimation and find "the average flux density over a single steradian" and multiply the result by $2\pi$, we get irradiance:</p>

<p>$$ (2\pi) \frac{1}{n}\sum^n L_{(x,\omega)} $$. 
But in this particular case, $2\pi$ has nothing to do with pdfs! since it's the integral domain used for the monte carlo estimation!</p>

<p>Instead, the real pdf is computed for $\theta$ and $\phi$ because that is the probability density function of choosing <strong>one direction over the other, according to the particular properties of a lambertian surface</strong>. A mirror-like surface has a different probability of choosing one direction over the other, but this has nothing to do us with dividing the sample with $\frac{1}{2\pi}$. It would be different if we were using importance sampling, but in this case it seems like we're not</p>

<p>Is my reasoning correct? If not, what am I missing?</p>

CC BY-SA 3.0
2017-12-09T03:04:25.760Z
the cdf's are (as far as i know) always computed from the pdf's of of each of the sperical coordinates, not from a probability function of solid angle. besides, a "bigger" solid angle is not well defined since you could choose any two shapes over the hemisphere with equal solid angle but vastly diferent probability
Sebastián Mestre
CC BY-SA 3.0
2017-12-09T20:39:46.007Z
Because the differential variable in your integral is dw and so the pdf would be a function of w. Hence the pdf = 1/2pi. If you instead write the differential variable dw as Sin(tetha)d(tetha)d(phi) as in fact dw equals this, then your pdf I think will be sin(tetha)/2pi. But it doesn't make difference as in this case the sin is cancelled out with the sin in the numinator and you will be left with 1/2pi.
ali
CC BY-SA 3.0
2017-12-10T12:42:09.443Z
which sin(theta) in the numerator cancels out with the sin in the pdf?
Row Rebel
CC BY-SA 3.0
2017-12-12T21:30:24.217Z
Sin(tetha) in the numerator comes from the solid angle definition which equals dw = sin(tetha) x d(phi) x d(tetha). And dw is what you have as differential variable in the main integral.
ali
CC BY-SA 3.0
2017-12-12T22:51:30.467Z
This is exactly the reason why the final PDF should be sin(theta) / 2pi the sin term doesn't cancel out
Row Rebel
CC BY-SA 3.0
2017-12-13T23:44:04.880Z
The illumination integral is L = integral E cos(tetha)sin(tetha) d(phi) d(tetha). Which has sin(tetha) as part of dw.
ali
CC BY-SA 3.0
2017-12-14T06:56:29.370Z
Sorry the above illumination integral should be L(out) = integral L brdf cos(tetha) sin(tetha) d(phi) d(tetha). And so its MC estimator will be <I> = L brdf cos(tetha) sin(tetha) / pdf. Here pdf will be in sin form. If you had your integral in terms of dw then your estimator would be <I> = L brdf cos(tetha) / pdf. The pdf here is 1/2pi.
ali
<raytracing><pathtracing><mathematics>
Probability density function while using spherical coordinates
Row Rebel
# Probability density function while using spherical coordinates

(Asked by: username_0 on 2017-12-09)

I'm following [this tutorial](https://www.scratchapixel.com/lessons/3d-basic-rendering/global-illumination-path-tracing/global-illumination-path-tracing-practical-implementation) where at somepoint the derived PDF for spherical coordinates for a Lambertian surface is

\begin{array}{l}
p(\theta, \phi) = \dfrac{\sin \theta}{2 \pi}.
\end{array}

But as soon as they compute a sample, the result is instead divided by $ \dfrac{1}{2\pi} $, which as they say is the "pdf of the integral"

Why isn't it divided by $ \frac{\sin \theta}{2 \pi} $ instead?

If we were using differential steradians over the unit hemisphere, the only possible probability density function integrating to 1 is infact $ \frac{1}{2\pi} $

But if we separate the integral over the hemisphere traced by spherical coordinates

$$
\int\_{\phi = 0}^{2\pi} \int\_{\theta = 0}^{\frac{\pi}{2}} \, \frac{\sin{\theta}}{2\pi}d\theta d\phi= 1.
$$

The PDF now becomes $ \frac{\sin \theta}{2 \pi} $ yet they still divide by $ \frac{1}{2\pi} $

EDIT: after carefully reviewing the concept of PDFs and integration over the hemisphere I'm starting to think the article I've linked is making a substantial error, mixing the idea of importance sampling with the pdf of choosing a direction of reflectance from a lambertian surface

Radiance is defined as
$$ L\_{(x,\omega)} = \frac{\mathrm{d}^2\Phi}{\mathrm{d}\omega\ cos\theta\ \mathrm{d}x} $$
Since it's defined over differential solid angles, we can interpret the result of one sample as if it was the flux density "over a unit steradian"

If we use monte carlo estimation and find "the average flux density over a single steradian" and multiply the result by $2\pi$, we get irradiance:

$$ (2\pi) \frac{1}{n}\sum^n L\_{(x,\omega)} $$.
But in this particular case, $2\pi$ has nothing to do with pdfs! since it's the integral domain used for the monte carlo estimation!

Instead, the real pdf is computed for $\theta$ and $\phi$ because that is the probability density function of choosing **one direction over the other, according to the particular properties of a lambertian surface**. A mirror-like surface has a different probability of choosing one direction over the other, but this has nothing to do us with dividing the sample with $\frac{1}{2\pi}$. It would be different if we were using importance sampling, but in this case it seems like we're not

Is my reasoning correct? If not, what am I missing?

**Tags:** raytracing, pathtracing, mathematics

> **Comments:**
> **username_1**: the cdf's are (as far as i know) always computed from the pdf's of of each of the sperical coordinates, not from a probability function of solid angle. besides, a "bigger" solid angle is not well defined since you could choose any two shapes over the hemisphere with equal solid angle but vastly diferent probability  
> **username_2**: Because the differential variable in your integral is dw and so the pdf would be a function of w. Hence the pdf = 1/2pi. If you instead write the differential variable dw as Sin(tetha)d(tetha)d(phi) as in fact dw equals this, then your pdf I think will be sin(tetha)/2pi. But it doesn't make difference as in this case the sin is cancelled out with the sin in the numinator and you will be left with 1/2pi.  
> **username_0**: which sin(theta) in the numerator cancels out with the sin in the pdf?  
> **username_2**: Sin(tetha) in the numerator comes from the solid angle definition which equals dw = sin(tetha) x d(phi) x d(tetha). And dw is what you have as differential variable in the main integral.  
> **username_0**: This is exactly the reason why the final PDF should be sin(theta) / 2pi the sin term doesn't cancel out  
> **username_2**: The illumination integral is L = integral E cos(tetha)sin(tetha) d(phi) d(tetha). Which has sin(tetha) as part of dw.  
> **username_2**: Sorry the above illumination integral should be L(out) = integral L brdf cos(tetha) sin(tetha) d(phi) d(tetha). And so its MC estimator will be <I> = L brdf cos(tetha) sin(tetha) / pdf. Here pdf will be in sin form. If you had your integral in terms of dw then your estimator would be <I> = L brdf cos(tetha) / pdf. The pdf here is 1/2pi.  

---

## 1 answers

### Answer by username_3 on 2017-12-21. Score: 0 | Accepted answer

Normally $sin(\theta)$ isn't written as part of the pdf, because it's an artifact from using double integral for spherical integration. The double integral does the integration over a rectangular domain (in you case of size $2\pi$ x $\pi/2$), while you want integration over a sphere/hemisphere, so $sin(\theta)$ is added there as a weight function to transform rectangular to spherical integration.

A common notation is to use integration over solid angle with single integral and differential solid angle $d\omega$ denoting 2D integration over sphere, and you won't see the $sin(\theta)$ term in there.

To clarify, the notation with single integral has constant infinitesimally small solid angle $d\omega$ over the sphere. However, for the double integral over $\theta$ and $\phi$ the solid angle isn't constant (think of [sphere tessellation](https://en.wikipedia.org/wiki/Sphere#/media/File:Sphere_wireframe_10deg_6r.svg)) but a function of $sin(\theta)$. In case of Monte Carlo integration and even distribution of samples over the hemisphere, each sample represents solid angle of $2\pi/N$ steradians and there's no $sin(\theta)$ solid angle weighting required.

> **Comments:**
> **username_0**: Yet they are choosing samples from a join pdf of theta and azimuth (as you said, double integral over a rectangle) but the resulting radiance is instead multiplied by 1 / 2pi  instead of sin(theta) / 2pi, why is that?  
> **username_3**: If you are referring to Monte Carlo integration, there's no weighting required because the samples are evenly distributed over the hemisphere by uniformSampleHemisphere() function, so each sample has the same the same solid angle. In the case of double integral the samples close to sphere poles have smaller solid angle which is compensated with the sin-term  
> **username_3**: Btw, if you would implement the integration with two nested sums over theta & phi, you would need to add the sin-term because the samples near poles would represent smaller solid angle than the samples at the equator.  
> **username_0**: So essentially since the integration is a single recursive sum, each  received differential radiance from a pixel represents the radiance along a single steradian and we multiply that by 2pi to estimate the irradiance arriving at point x, to finally multiply that value with the BRDF to see how much of that irradiance arrives to the camera?  
> **username_3**: For hemispherical integration with even sample distribution (no biasing towards any region), each sample covers 2pi/n sr (hemisphere=2pi sr). So for the rendering equation you just add up all the samples multiplied by the solid angle for each sample (sample=incident radiance * brdf * cos(theta)) to calculate the total radiance from a pixel towards the eye.  

---

