<p>Most of the answer is in the text you linked:</p>

<blockquote>
  <p>Shapes almost always sample uniformly by area on their surface.
  Therefore, we will provide a default implementation of the
  Shape::Pdf() method corresponding to this sampling approach that
  returns the corresponding PDF: 1 over the surface area.</p>
</blockquote>

<p>So it is not always 1. This is just the most basic way to sample a light. It is simple, fast and provides a good baseline to check other algorithms for correctness. As for:</p>

<blockquote>
  <p>Assuming for example a sphere light source (but a cylinder would also
  do), if in the second formula above we use the entire sphere area as
  <span class="math-container">$A$</span>, aren't we using a solid angle for the sphere which is double of
  what it actually should be? (by including the half surface we cannot
  see from <span class="math-container">$p$</span>:</p>
</blockquote>

<p>The half you cannot see will simply be excluded by the visibiliy test. Or because it is back facing, if you choose to emit light only on one side of the object. A better sampling algorithm will take that into consideration and adjust the PDF accordingly. Indeed, if you read a little further on that page, you will find:</p>

<blockquote>
  <p>The second shape sampling method takes the point from which the
  surface of the shape is being integrated over as a parameter. This
  method is particularly useful for lighting, since the caller can pass
  in the point to be lit and allow shape implementations to ensure that
  they only sample the portion of the shape that is potentially visible
  from that point.</p>
</blockquote>

<p>Which is exactly what you are asking about. But doing this is not about having correct sampling, it's about having efficient sampling. Any sampling method is correct as long as:</p>

<ol>
<li>It can generate samples everywhere they are potentially needed.</li>
<li>Its PDF correctly represents the probability of generating each sample.</li>
</ol>

CC BY-SA 4.0
2020-04-12T20:53:57.833Z
2020-04-12T20:53:57.833Z
Olivier
<p>I have a doubt regarding shape lights pdfs, specifically various sources point at the fact that the pdf is a constant:</p>

<p><span class="math-container">$$
lightpdf = 1/A
$$</span></p>

<p>Where <span class="math-container">$A$</span> is the area of the light surface. Expressed in solid angle terms, this becomes:
<span class="math-container">$$
lightpdf(\omega) = \frac{r^2}{cos\theta A}
$$</span></p>

<p>or <span class="math-container">$= 0$</span> for directions on the hemisphere which do not hit the light.</p>

<p>Where <span class="math-container">$r^2$</span> is the squared distance from the hit point o the light surface and the point we are sampling from, and <span class="math-container">$\theta$</span> the angle from the light surface normal and our ray direction (<a href="http://www.pbr-book.org/3ed-2018/Light_Transport_I_Surface_Reflection/Sampling_Light_Sources.html#SamplingShapes" rel="nofollow noreferrer">source</a>).</p>

<p>What isn't clear to me is knowing that the pdf should satisfy this condition:</p>

<p><span class="math-container">$$\int_0^{2\pi} lightpdf(\omega)d\omega = 1$$</span></p>

<p>Assuming for example a sphere light source (but a cylinder would also do), if in the second formula above we use the entire sphere area as <span class="math-container">$A$</span>, aren't we using a solid angle for the sphere which is double of what it actually should be? (by including the half surface we cannot see from <span class="math-container">$p$</span>:</p>

<p><a href="https://i.sstatic.net/Yu2GP.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/Yu2GP.png" alt="enter image description here"></a></p>

CC BY-SA 4.0
2020-04-12T18:55:49.190Z
It doesn't have to satisfy $\int_{0}^{2\pi}lightpdf(\omega)\,d\omega$.
lightxbulb
CC BY-SA 4.0
2020-04-13T02:45:04.627Z
@lightxbulb Why not? Using a BRDF shouldn't it be 1 over our support? $2\pi$
yggdrasil
CC BY-SA 4.0
2020-04-13T05:52:18.757Z
1) Your pdf support is not $[0,2\pi]$, it's the area of the light. 2) The solid angle formulation doesn't result in an integral in [0,2\pi]. 3) `including the half surface we cannot see from p:` - this is taken care of by the visibility function when sampling lights.
lightxbulb
CC BY-SA 4.0
2020-04-13T06:36:32.523Z
@lightxbulb Hmm I see, thanks for the clarification! However let's assume for a moment we have a weirdly shaped light which covers the entire BRDF hemisphere (and has a back and front face). In that case by randomly sampling its surface our support in solid angle terms should be $4\pi$ and the pdf $r^2/cos\theta A$ (or in area terms $A$ and $1/A$ respectively) However thanks to the visibility function, samples on the back side ($2\pi$) will be 0. Is my understanding correct?
yggdrasil
CC BY-SA 4.0
2020-04-13T07:45:18.697Z
No, the solid angle support will be still $2\pi$, since angles are considered and not surface points, those are taken care of by the visibility function. Rewrite it in the area formulation to get a better idea.
lightxbulb
CC BY-SA 4.0
2020-04-13T08:47:43.470Z
@lightxbulb Ok, so if the support is still $2\pi$ in the above example, each direction actually hits two points on the light surface (front and back), but the latter is discarded by the visibility function. Did I get it correctly? In the area formulation case, samples taken on the back face are also discarded by the visibility function.
yggdrasil
CC BY-SA 4.0
2020-04-13T09:58:58.940Z
The visibility is implicit in the solid angle formulation of the rendering equation in the $L_i$ term and the integration domain. In the area formulation it is explicit and the integration domain is larger. As for the pdf integrating to one - that cannot be written in the solid angle formulation in the general case without decomposing it into a sum over several integrals, simply because the "back" surface kf the sphere won't be visible from some points.
lightxbulb
<lighting><importance-sampling>
Confusion about light PDF
yggdrasil
# Confusion about light PDF

(Asked by: username_0 on 2020-04-12)

I have a doubt regarding shape lights pdfs, specifically various sources point at the fact that the pdf is a constant:

$$
lightpdf = 1/A
$$

Where $A$ is the area of the light surface. Expressed in solid angle terms, this becomes:
$$
lightpdf(\omega) = \frac{r^2}{cos\theta A}
$$

or $= 0$ for directions on the hemisphere which do not hit the light.

Where $r^2$ is the squared distance from the hit point o the light surface and the point we are sampling from, and $\theta$ the angle from the light surface normal and our ray direction ([source](http://www.pbr-book.org/3ed-2018/Light_Transport_I_Surface_Reflection/Sampling_Light_Sources.html#SamplingShapes)).

What isn't clear to me is knowing that the pdf should satisfy this condition:

$$\int\_0^{2\pi} lightpdf(\omega)d\omega = 1$$

Assuming for example a sphere light source (but a cylinder would also do), if in the second formula above we use the entire sphere area as $A$, aren't we using a solid angle for the sphere which is double of what it actually should be? (by including the half surface we cannot see from $p$:

[![enter image description here](https://i.sstatic.net/Yu2GP.png)](https://i.sstatic.net/Yu2GP.png)

**Tags:** lighting, importance-sampling

> **Comments:**
> **username_1**: It doesn't have to satisfy $\int_{0}^{2\pi}lightpdf(\omega)\,d\omega$.  
> **username_0**: @username_1 Why not? Using a BRDF shouldn't it be 1 over our support? $2\pi$  
> **username_1**: 1) Your pdf support is not $[0,2\pi]$, it's the area of the light. 2) The solid angle formulation doesn't result in an integral in [0,2\pi]. 3) `including the half surface we cannot see from p:` - this is taken care of by the visibility function when sampling lights.  
> **username_0**: @username_1 Hmm I see, thanks for the clarification! However let's assume for a moment we have a weirdly shaped light which covers the entire BRDF hemisphere (and has a back and front face). In that case by randomly sampling its surface our support in solid angle terms should be $4\pi$ and the pdf $r^2/cos\theta A$ (or in area terms $A$ and $1/A$ respectively) However thanks to the visibility function, samples on the back side ($2\pi$) will be 0. Is my understanding correct?  
> **username_1**: No, the solid angle support will be still $2\pi$, since angles are considered and not surface points, those are taken care of by the visibility function. Rewrite it in the area formulation to get a better idea.  
> **username_0**: @username_1 Ok, so if the support is still $2\pi$ in the above example, each direction actually hits two points on the light surface (front and back), but the latter is discarded by the visibility function. Did I get it correctly? In the area formulation case, samples taken on the back face are also discarded by the visibility function.  
> **username_1**: The visibility is implicit in the solid angle formulation of the rendering equation in the $L_i$ term and the integration domain. In the area formulation it is explicit and the integration domain is larger. As for the pdf integrating to one - that cannot be written in the solid angle formulation in the general case without decomposing it into a sum over several integrals, simply because the "back" surface kf the sphere won't be visible from some points.  

---

## 1 answers

### Answer by username_2 on 2020-04-12. Score: 1 | Accepted answer

Most of the answer is in the text you linked:

> Shapes almost always sample uniformly by area on their surface.
> Therefore, we will provide a default implementation of the
> Shape::Pdf() method corresponding to this sampling approach that
> returns the corresponding PDF: 1 over the surface area.

So it is not always 1. This is just the most basic way to sample a light. It is simple, fast and provides a good baseline to check other algorithms for correctness. As for:

> Assuming for example a sphere light source (but a cylinder would also
> do), if in the second formula above we use the entire sphere area as
> $A$, aren't we using a solid angle for the sphere which is double of
> what it actually should be? (by including the half surface we cannot
> see from $p$:

The half you cannot see will simply be excluded by the visibiliy test. Or because it is back facing, if you choose to emit light only on one side of the object. A better sampling algorithm will take that into consideration and adjust the PDF accordingly. Indeed, if you read a little further on that page, you will find:

> The second shape sampling method takes the point from which the
> surface of the shape is being integrated over as a parameter. This
> method is particularly useful for lighting, since the caller can pass
> in the point to be lit and allow shape implementations to ensure that
> they only sample the portion of the shape that is potentially visible
> from that point.

Which is exactly what you are asking about. But doing this is not about having correct sampling, it's about having efficient sampling. Any sampling method is correct as long as:

1. It can generate samples everywhere they are potentially needed.
2. Its PDF correctly represents the probability of generating each sample.


---

