7
$\begingroup$

I have been following the scratchapixel ray tracing tutorials online which have been great at explaining the theory behind everything & how to implement it. However, I reached the point where I want to implement Area Lights but I am clueless on how to do it. The tutorial on the website hasn't been uploaded yet (all though there is a placeholder link with a bunch of others).

There's not much online regarding implementation so this has lead me here. Could someone please explain how I can implement Area Lights with Ray Tracing as opposed to Point Lights?

enter image description here

$\endgroup$
  • $\begingroup$ Just checking... this is ray tracing right, not path tracing? $\endgroup$ – Alan Wolfe Dec 2 '16 at 17:54
  • $\begingroup$ I meant to say Path Tracing, will change the title. $\endgroup$ – Arjan Singh Dec 2 '16 at 18:17
7
$\begingroup$

I'm going to provide the simple/naive/brute force answer to this question, which does work, and gives accurate results.

There are better answers however, which make the rendering converge faster with fewer samples, but uses more advanced math. I'm hoping someone else will provide an answer along those lines.

The simple answer is this: Area lights are just geometry which have an emissive value.

To add support for emissive values to path tracing is pretty easy luckily.

As you know, the amount of light heading towards a pixel is the amount of light leaving the surface that a ray down that pixel would intersect.

That is calculated recursively by seeing how much light is hitting that point, integrating the BRDF, multiplying by the cosine and all that jazz.

Emissive lighting is just added to that result. So, whatever you have now as "outgoing light" from a surface, just add to it the emissive color of that surface. (You could also optionally do something similar to texture mapping and have emissive values vary over the object, possibly based on a texture).

That's all there is to it, it's very simple and easy.

In the rendering equation below, $L_e(\omega_o)$ represents the emissive term (that's what the e stands for, emissive), and the rest of the equation is the light integrated over the hemisphere. You can see that you just add the emissive to the result you return as your outgoing light from a point ($L_o( \omega_o)$) to apply that emissive lighting.

$L_o( \omega_o)= L_e(\omega_o)+\int_{\Omega}{f(\omega_i, \omega_o)L_i(\omega_i)(\omega_i \cdot n)\mathrm{d}\omega_i}$

You can read more about a simple path tracer with area lights at this link, which also has commented C++ source code.

http://blog.demofox.org/2016/09/21/path-tracing-getting-started-with-diffuse-and-emissive/

enter image description here

$\endgroup$
  • $\begingroup$ Great Answer this really clarified everything, although I'm going off topic a little would you know of any good resources on how to implement depth of field? $\endgroup$ – Arjan Singh Dec 3 '16 at 6:08
  • 1
    $\begingroup$ No sorry, but I am interested too. Ask another question IMO! $\endgroup$ – Alan Wolfe Dec 3 '16 at 6:09
  • $\begingroup$ How do I calculate the light direction for use in a Ray Tracer to first calculate the Direct Lighting though? Do I even need to do that? I am little confused here. $\endgroup$ – Arjan Singh May 28 '17 at 12:53
  • $\begingroup$ You don't need to do that, no. You just shoot random rays in the hemisphere, and some of them will hit the light, some of them won't. There are techniques to shoot rays at the lights more directly while still accounting for the probability of you having chosen them randomly (to make the image look the same), but it's not required, no. $\endgroup$ – Alan Wolfe May 28 '17 at 14:20
  • $\begingroup$ I'm still really confused (I'm sorry), but wouldn't this only work for Indirect lighting and not Direct Lighting? Could you add some code to your answer to illustrate this clearer? I looked at the source for path tracer in the blog post on GitHub but I couldn't understand what was going on. $\endgroup$ – Arjan Singh May 28 '17 at 14:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.