# Path tracing: how to deal with ray hitting an emitter

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): 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?

• 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... Feb 6 at 8:23
• 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. Feb 6 at 10:13
• 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). Feb 6 at 16:17
• 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). Feb 6 at 19:02

I am guessing I had an misunderstanding here. Just as @lightxbulb 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, 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.