<p>I am guessing I had an misunderstanding here. Just as @lightxbulb said, cos term and distance attenuation do not come from <span class="math-container">$L_e$</span>, yet I haven't quite understand why until recent days when I come to notice <strong>the measure of an integral</strong> and what exactly I am evaluating during <span class="math-container">$L_e$</span> evaluation.</p>
<p>From <a href="https://www.pbr-book.org/3ed-2018/Light_Transport_I_Surface_Reflection/The_Light_Transport_Equation#TheSurfaceFormoftheLTE" rel="nofollow noreferrer">PBR-book: 14.4.3 The Surface Form of the LTE</a>, I understand the difference of <span class="math-container">$dA$</span> and <span class="math-container">$dw$</span>, and how geometry term plays an important part in converting one measure to the other. Since <span class="math-container">$L_e$</span> evaluation has nothing to do with integration (the ray directly intersects the emitter), <span class="math-container">$L_e$</span> evaluation function returns <strong>radiance</strong> directly, which is related to the direction of the ray and requires no measure conversion. Also, since there is no participating medium, radiance from one point to another should remain the same all the way.</p>
<p>I guess the main misunderstanding is that, I perceived emission evaluation as some kind of <em>illuminating by sampling the area emitter</em> problem, which is not the same.</p>
<p>Guessing laying a solid foundation does help a lot.</p>

CC BY-SA 4.0
2023-02-18T05:58:03.737Z
2023-02-18T05:58:03.737Z
Enigmatisms
<p>I am writing my first path tracer and kind of feeling confused by some mechanisms. For example, when I trace a ray and the ray hits a area emitter, then how to determine the radiance of this direct hit? I know that in rendering equation, we have:</p>
<p><span class="math-container">$L_o(w_o, x) = L_e(w_o, x) + \int f_r(w_i, w_o, x)\cos \theta dw_i$</span></p>
<p>and here I should determine what <span class="math-container">$L_e(w_o, x)$</span> is. My question is, for <span class="math-container">$L_e(w_o, x)$</span> here, should it incorporate distance attenuation (e.g. for area light, pow(distance, 2)) and <span class="math-container">$\cos$</span> term? Because I've noticed that if I scale down the <code>emission_part</code> of when calculating the following code:</p>
<pre><code>color = (direct_part + emission_part) * throughput
</code></pre>
<p>The rendering actually converges <strong>several times faster</strong> (though I think it will lead to biased results), and the there is less aliasing effect around the emitter. Also, I tried to understand how other renderers cope with this situation (like mitsuba2, <code>path.cpp</code>):</p>
<pre><code>result[active] += emission_weight * throughput * emitter-&gt;eval(si, active);
</code></pre>
<p>I don't see how <code>emitter-&gt;eval(si, active)</code> above leveraging <code>si</code> (surface interaction vertex), like calculating distance attenuation to the sampled intensity, <code>mitsuba2</code> just uses <code>Texture::eval(...)</code> to calculate the emitted radiance. Therefore, I think this is the reason for its rendering result to have no saw-tooth aliasing anywhere but places around the emitter (see the figure below: cornell box scene with area emitter):</p>
<p><img src="https://i.sstatic.net/122CO.png" alt="cornellbox" /></p>
<p>So, should I just use the formulation below, just like evaluating direct illumination</p>
<pre><code>ret_int = emitter.intensity * distance_attenuate(ray_length) * cosine_term
</code></pre>
<p>Or simply returns its original intensity:</p>
<pre><code>ret_int = emitter.intensity
</code></pre>
<p>When dealing with ray hitting an emitter?</p>

CC BY-SA 4.0
2023-02-06T08:23:50.910Z
Since radiance attenuates according to inverse-square law, I made my emitters have emission values bigger than 1.0. So if I don't add distance attenuation term when evaluating emission radiance, the image will be *overexposed* and I can't tell the color of the emitter (pure white). But if I add the distance attenuation term, the rendered image will be extremely dark and the emitter can not be seen in the image...
Enigmatisms
CC BY-SA 4.0
2023-02-06T10:13:20.747Z
There is no cosine or distance attenuation term, unless it is a pointlight - then there is attenuation but it's not from the light itself but rather the area formulation. To be sure, you can add a cosine wrt the light's normal, but that wouldn't be because of some property of radiance but rather because you chose such an emission profile.
lightxbulb
CC BY-SA 4.0
2023-02-06T16:17:32.727Z
I guess this is the case, but something just seems to contradict my understanding. If I consider ray hitting the emitter to be "the emitter directly illuminates the sensor", then it seems that we should add attenuation term for a specific point on the area source. And as for the point source, I won't be able to hit it anyway so there will never be an $L_e$, right? I am just wondering why direct illumination (by sampling shadow rays) is so different from ray hitting the emitter when evaluating the radiance (for the former ones, there will be attenuation terms, while the latter doesn't).
Enigmatisms
CC BY-SA 4.0
2023-02-06T19:02:51.750Z
You can sample point sources directly using next event estimation/shadow rays. In fact that's the only way to sample those. The cosine term and reciprocal square distance doesn't come from the $L_e$ term. It is the result of integrating wrt surface area instead of solid angle. The relation between the differential forms is $d\omega = \frac{\cos\theta}{r^2}dA$, which is where these terms come from. You can derive it from the divergence theorem. When you sample a bsdf you do that wrt solid angle. When you sample lights this is typically done wrt the area formulation (though not necessarily).
lightxbulb
<rendering><pathtracing><global-illumination>
Path tracing: how to deal with ray hitting an emitter
Enigmatisms
# Path tracing: how to deal with ray hitting an emitter

(Asked by: username_0 on 2023-02-06)

I am writing my first path tracer and kind of feeling confused by some mechanisms. For example, when I trace a ray and the ray hits a area emitter, then how to determine the radiance of this direct hit? I know that in rendering equation, we have:

$L\_o(w\_o, x) = L\_e(w\_o, x) + \int f\_r(w\_i, w\_o, x)\cos \theta dw\_i$

and here I should determine what $L\_e(w\_o, x)$ is. My question is, for $L\_e(w\_o, x)$ here, should it incorporate distance attenuation (e.g. for area light, pow(distance, 2)) and $\cos$ term? Because I've noticed that if I scale down the `emission_part` of when calculating the following code:

```
color = (direct_part + emission_part) * throughput

```

The rendering actually converges **several times faster** (though I think it will lead to biased results), and the there is less aliasing effect around the emitter. Also, I tried to understand how other renderers cope with this situation (like mitsuba2, `path.cpp`):

```
result[active] += emission_weight * throughput * emitter->eval(si, active);

```

I don't see how `emitter->eval(si, active)` above leveraging `si` (surface interaction vertex), like calculating distance attenuation to the sampled intensity, `mitsuba2` just uses `Texture::eval(...)` to calculate the emitted radiance. Therefore, I think this is the reason for its rendering result to have no saw-tooth aliasing anywhere but places around the emitter (see the figure below: cornell box scene with area emitter):

![cornellbox](https://i.sstatic.net/122CO.png)

So, should I just use the formulation below, just like evaluating direct illumination

```
ret_int = emitter.intensity * distance_attenuate(ray_length) * cosine_term

```

Or simply returns its original intensity:

```
ret_int = emitter.intensity

```

When dealing with ray hitting an emitter?

**Tags:** rendering, pathtracing, global-illumination

> **Comments:**
> **username_0**: Since radiance attenuates according to inverse-square law, I made my emitters have emission values bigger than 1.0. So if I don't add distance attenuation term when evaluating emission radiance, the image will be *overexposed* and I can't tell the color of the emitter (pure white). But if I add the distance attenuation term, the rendered image will be extremely dark and the emitter can not be seen in the image...  
> **username_1**: There is no cosine or distance attenuation term, unless it is a pointlight - then there is attenuation but it's not from the light itself but rather the area formulation. To be sure, you can add a cosine wrt the light's normal, but that wouldn't be because of some property of radiance but rather because you chose such an emission profile.  
> **username_0**: I guess this is the case, but something just seems to contradict my understanding. If I consider ray hitting the emitter to be "the emitter directly illuminates the sensor", then it seems that we should add attenuation term for a specific point on the area source. And as for the point source, I won't be able to hit it anyway so there will never be an $L_e$, right? I am just wondering why direct illumination (by sampling shadow rays) is so different from ray hitting the emitter when evaluating the radiance (for the former ones, there will be attenuation terms, while the latter doesn't).  
> **username_1**: You can sample point sources directly using next event estimation/shadow rays. In fact that's the only way to sample those. The cosine term and reciprocal square distance doesn't come from the $L_e$ term. It is the result of integrating wrt surface area instead of solid angle. The relation between the differential forms is $d\omega = \frac{\cos\theta}{r^2}dA$, which is where these terms come from. You can derive it from the divergence theorem. When you sample a bsdf you do that wrt solid angle. When you sample lights this is typically done wrt the area formulation (though not necessarily).  

---

## 1 answers

### Answer by username_0 on 2023-02-18. Score: 2 | Accepted answer

I am guessing I had an misunderstanding here. Just as @username_1 said, cos term and distance attenuation do not come from $L\_e$, yet I haven't quite understand why until recent days when I come to notice **the measure of an integral** and what exactly I am evaluating during $L\_e$ evaluation.

From [PBR-book: 14.4.3 The Surface Form of the LTE](https://www.pbr-book.org/3ed-2018/Light_Transport_I_Surface_Reflection/The_Light_Transport_Equation#TheSurfaceFormoftheLTE), I understand the difference of $dA$ and $dw$, and how geometry term plays an important part in converting one measure to the other. Since $L\_e$ evaluation has nothing to do with integration (the ray directly intersects the emitter), $L\_e$ evaluation function returns **radiance** directly, which is related to the direction of the ray and requires no measure conversion. Also, since there is no participating medium, radiance from one point to another should remain the same all the way.

I guess the main misunderstanding is that, I perceived emission evaluation as some kind of *illuminating by sampling the area emitter* problem, which is not the same.

Guessing laying a solid foundation does help a lot.


---

