<p>I think, first, you should know what <code>SampleLi()</code> does in the code. In both UDPT and BDPT, <code>SampleLi()</code> is used in next event estimation (sample a point on the light source and evaluate direct illumination). That is to say, the return value of <code>SampleLi()</code> is directly propagated to the illuminated point and we want to estimate the reflected radiance.</p>
<p>According to <a href="https://pbr-book.org/3ed-2018/Color_and_Radiometry/Surface_Reflection" rel="nofollow noreferrer">pbr-book: surface-reflection</a>, we should be evaluating:
<span class="math-container">$$
\int_{S^2}f(p,\omega_o, \omega_i)\underbrace{L_i(p, \omega_i)|\cos\theta_i|d\omega_i}_{\text{differential irradiance}}
$$</span>
As mentioned by Nathan, point source is infinitesimal and subtends zero solid angle, therefore we can't define the radiance term <span class="math-container">$L_i$</span> simply. However, it simple for area sources, since <code>SampleLi()</code> will sample a point (actually, a differential area) via area measure and the differential area sampled will subtend a valid solid angle. Therefore, for the differential irradiance at illuminated point <code>p</code>:</p>
<ul>
<li><code>SampleLi()</code> will return radiance (and PDF, important). Radiance will be converted to irradiance through the PDF, which includes geometry term for this conversion (including inverse sqr distance). I am taking the code of pbrt-v3 as an example since I think it is simpler to follow:</li>
</ul>
<pre class="lang-cpp prettyprint-override"><code>// SampleLi for diffuse area emitter: src/lights/diffuse.cpp
Spectrum DiffuseAreaLight::Sample_Li(const Interaction &amp;ref, const Point2f &amp;u,
                                     Vector3f *wi, Float *pdf,
                                     VisibilityTester *vis) const {
    ProfilePhase _(Prof::LightSample);
    Interaction pShape = shape-&gt;Sample(ref, u, pdf);
    pShape.mediumInterface = mediumInterface;
    if (*pdf == 0 || (pShape.p - ref.p).LengthSquared() == 0) {
        *pdf = 0;
        return 0.f;
    }
    *wi = Normalize(pShape.p - ref.p);
    *vis = VisibilityTester(ref, pShape);
    return L(pShape, -*wi);
}
// the Sampling PDF calculated in SampleLi: src/core/shape.cpp
Interaction Shape::Sample(const Interaction &amp;ref, const Point2f &amp;u,
                          Float *pdf) const {
    Interaction intr = Sample(u, pdf);
    Vector3f wi = intr.p - ref.p;
    if (wi.LengthSquared() == 0)
        *pdf = 0;
    else {
        wi = Normalize(wi);
        // Convert from area measure, as returned by the Sample() call
        // above, to solid angle measure.
        *pdf *= DistanceSquared(ref.p, intr.p) / AbsDot(intr.n, -wi);
        if (std::isinf(*pdf)) *pdf = 0.f;
    }
    return intr;
}
// How the Sample_Li gets called: src/core/integrator.cpp
...
Spectrum Li = light.Sample_Li(it, uLight, &amp;wi, &amp;lightPdf, &amp;visibility);
...
Ld += f * Li / lightPdf;       // Let's ignore MIS for a sec
</code></pre>
<p><code>lightPdf</code> actually accounts for the distance attenuation, just as what Nathan said (quoted here):</p>
<blockquote>
<p>with area lights, the distance attenuation comes naturally as a result of the light subtending less solid angle from the receiver's point of view, when the receiver is farther away</p>
</blockquote>
<ul>
<li>SampleLi() will directly return irradiance for point sources. This is actually  the differential irradiance we need to evaluated the local reflection equation (with BRDF).</li>
</ul>
<p>So in my opinion, the goal of <code>SampleLi()</code>, since it is used in next event estimation, is to somehow get the differential irradiance at <code>p</code>. For point sources, this differential irradiance is deterministic --- it is the irradiance of the point source at 3D position <code>p</code>. While for area sources, we should get this irradiance from the conversion of radiance from a certain differential area. As the goal is actually (differential) <strong>irradiance</strong>, <code>SampleLi()</code> of point source directly return the irradiance at <code>p</code>.</p>
<p>I drew a figure and hope this would help you understand. Feel free to point out any mistake I made in this post.</p>
<p><a href="https://i.sstatic.net/Q93gP.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/Q93gP.png" alt="enter image description here" /></a></p>

CC BY-SA 4.0
2024-03-21T15:12:22.927Z
Hi! Thanks for answering!
So when we evaluate the integral you mentioned for Li with monte-carlo follows like [this](https://www.pbr-book.org/3ed-2018/Light_Transport_I_Surface_Reflection).
According to this, $dE = L_i|cos\theta_i| / pdf$ (approximating $L_i|cos\theta_i|d\omega_i$). In case of area light, because of uniform sampling the shape, the pdf = 1.0/area wrt area, but you have to convert it wrt solid angle to get the right quantity for the diff irradiance (dE).
So basically in this case the pdf has to have the unit of 1/sr as well.
Balu
CC BY-SA 4.0
2024-03-21T15:19:39.070Z
https://www.pbr-book.org/3ed-2018/Light_Transport_I_Surface_Reflection/Sampling_Light_Sources#SamplingShapes
Balu
CC BY-SA 4.0
2024-03-25T12:36:47.477Z
Am I right @Enigmatisms?
Balu
CC BY-SA 4.0
2024-03-26T01:49:20.327Z
Yes, because in this case you are integrating over the hemisphere.
Enigmatisms
CC BY-SA 4.0
2024-03-26T12:29:56.313Z
thanks very much!
Balu
CC BY-SA 4.0
2024-03-20T02:24:30.607Z
2024-03-20T02:24:30.607Z
Enigmatisms
<p>I was reading <a href="https://computergraphics.stackexchange.com/questions/10284/deriving-radiance-from-irradiance-and-intensity">Deriving radiance from irradiance and intensity</a> and the last comment said that by dividing <span class="math-container">$r^2$</span> we convert radiant intensity to irradiance. What confuses me then is the fact that for point lights in <a href="https://pbr-book.org/4ed/Light_Sources/Point_Lights" rel="nofollow noreferrer">pbrt</a> it seems the SampleLi() function returns the irradiance not the radiance. What am I missing? Is it that in this case the irradiance equals the radiance because from the receiver's point of view all the irradiance is coming from one (delta) direction therefore R=E?</p>

<raytracing><pathtracing><physically-based><pbrt>
Point light source radiance
Balu
# Point light source radiance

(Asked by: username_0 on 2024-03-19)

I was reading [Deriving radiance from irradiance and intensity](https://computergraphics.stackexchange.com/questions/10284/deriving-radiance-from-irradiance-and-intensity) and the last comment said that by dividing $r^2$ we convert radiant intensity to irradiance. What confuses me then is the fact that for point lights in [pbrt](https://pbr-book.org/4ed/Light_Sources/Point_Lights) it seems the SampleLi() function returns the irradiance not the radiance. What am I missing? Is it that in this case the irradiance equals the radiance because from the receiver's point of view all the irradiance is coming from one (delta) direction therefore R=E?

**Tags:** raytracing, pathtracing, physically-based, pbrt


---

## 1 answers

### Answer by username_1 on 2024-03-20. Score: 3 | Accepted answer

I think, first, you should know what `SampleLi()` does in the code. In both UDPT and BDPT, `SampleLi()` is used in next event estimation (sample a point on the light source and evaluate direct illumination). That is to say, the return value of `SampleLi()` is directly propagated to the illuminated point and we want to estimate the reflected radiance.

According to [pbr-book: surface-reflection](https://pbr-book.org/3ed-2018/Color_and_Radiometry/Surface_Reflection), we should be evaluating:
$$
\int\_{S^2}f(p,\omega\_o, \omega\_i)\underbrace{L\_i(p, \omega\_i)|\cos\theta\_i|d\omega\_i}\_{\text{differential irradiance}}
$$
As mentioned by Nathan, point source is infinitesimal and subtends zero solid angle, therefore we can't define the radiance term $L\_i$ simply. However, it simple for area sources, since `SampleLi()` will sample a point (actually, a differential area) via area measure and the differential area sampled will subtend a valid solid angle. Therefore, for the differential irradiance at illuminated point `p`:

* `SampleLi()` will return radiance (and PDF, important). Radiance will be converted to irradiance through the PDF, which includes geometry term for this conversion (including inverse sqr distance). I am taking the code of pbrt-v3 as an example since I think it is simpler to follow:

```cpp
// SampleLi for diffuse area emitter: src/lights/diffuse.cpp
Spectrum DiffuseAreaLight::Sample_Li(const Interaction &ref, const Point2f &u,
                                     Vector3f *wi, Float *pdf,
                                     VisibilityTester *vis) const {
    ProfilePhase _(Prof::LightSample);
    Interaction pShape = shape->Sample(ref, u, pdf);
    pShape.mediumInterface = mediumInterface;
    if (*pdf == 0 || (pShape.p - ref.p).LengthSquared() == 0) {
        *pdf = 0;
        return 0.f;
    }
    *wi = Normalize(pShape.p - ref.p);
    *vis = VisibilityTester(ref, pShape);
    return L(pShape, -*wi);
}
// the Sampling PDF calculated in SampleLi: src/core/shape.cpp
Interaction Shape::Sample(const Interaction &ref, const Point2f &u,
                          Float *pdf) const {
    Interaction intr = Sample(u, pdf);
    Vector3f wi = intr.p - ref.p;
    if (wi.LengthSquared() == 0)
        *pdf = 0;
    else {
        wi = Normalize(wi);
        // Convert from area measure, as returned by the Sample() call
        // above, to solid angle measure.
        *pdf *= DistanceSquared(ref.p, intr.p) / AbsDot(intr.n, -wi);
        if (std::isinf(*pdf)) *pdf = 0.f;
    }
    return intr;
}
// How the Sample_Li gets called: src/core/integrator.cpp
...
Spectrum Li = light.Sample_Li(it, uLight, &wi, &lightPdf, &visibility);
...
Ld += f * Li / lightPdf;       // Let's ignore MIS for a sec

```

`lightPdf` actually accounts for the distance attenuation, just as what Nathan said (quoted here):

> with area lights, the distance attenuation comes naturally as a result of the light subtending less solid angle from the receiver's point of view, when the receiver is farther away

* SampleLi() will directly return irradiance for point sources. This is actually the differential irradiance we need to evaluated the local reflection equation (with BRDF).

So in my opinion, the goal of `SampleLi()`, since it is used in next event estimation, is to somehow get the differential irradiance at `p`. For point sources, this differential irradiance is deterministic --- it is the irradiance of the point source at 3D position `p`. While for area sources, we should get this irradiance from the conversion of radiance from a certain differential area. As the goal is actually (differential) **irradiance**, `SampleLi()` of point source directly return the irradiance at `p`.

I drew a figure and hope this would help you understand. Feel free to point out any mistake I made in this post.

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

> **Comments:**
> **username_0**: Hi! Thanks for answering! So when we evaluate the integral you mentioned for Li with monte-carlo follows like [this](https://www.pbr-book.org/3ed-2018/Light_Transport_I_Surface_Reflection). According to this, $dE = L_i|cos\theta_i| / pdf$ (approximating $L_i|cos\theta_i|d\omega_i$). In case of area light, because of uniform sampling the shape, the pdf = 1.0/area wrt area, but you have to convert it wrt solid angle to get the right quantity for the diff irradiance (dE). So basically in this case the pdf has to have the unit of 1/sr as well.  
> **username_0**: https://www.pbr-book.org/3ed-2018/Light_Transport_I_Surface_Reflection/Sampling_Light_Sources#SamplingShapes  
> **username_0**: Am I right @username_1?  
> **username_1**: Yes, because in this case you are integrating over the hemisphere.  
> **username_0**: thanks very much!  

---

