Sign in to follow this  

Area Lights with Deferred Renderer?

Recommended Posts



In my deferred renderer I wanted to add support for area lights. I've been thinking all night for a nice way to do them, but I can't figure it out.


Similar to a spot light, do I draw a frustum mesh instead of a cone mesh? How do I calculate attenuation in the shader? How do I generate the lights frustum matrix?


I have no idea what I'm doing in this situation!

Edited by orange451

Share this post

Link to post
Share on other sites

Haha, I fear you are tackling one of the remaining not-so-easy-to-fix problems in realtime rendering: area lights.


First the nice part: Implementing an area light is not tooooo hard. There's a lot of info right on this board, too, from Arkano22, which I once used to implement arealights too. Have a look at

You can use a rotated box mesh, or an AABB to keep things simple. First attempt could be an expensive full screen pass. Arkano also has a hint on how to have textured area lights, with texture projection, but at least he tells you how to implement attenuation.


The next thing would be to be more physically plausible and correct - you can find an article in the latest GPU Pro 5, right from the Killzone developers, about how to implement good specular reflections for realtime area lights. Basically, they do a single-ray importance sampling. But that's probably overkill for you right now.

Edited by hannesp

Share this post

Link to post
Share on other sites

I have actually implemented Arkano's method long time ago (around the time he posted it) and further extended it.


The original idea there is to compute attenuation based on distance from given object (he used planes only as far as I remember, this can be easily extended to spheres, tubes, triangle(s)). Specular lighting can be implemented in a nice (phong-like) way by using a single ray to perform a "real" reflection of the geometric object. Diffuse still looks good when using just a single point (F.e. the center of the object) - unless the light is too big. Use this with textures and ideally project them along with diffuse (+ use mip maps to blur it) and you've got an awesome lighting system.


If you want a more physically-based solution, well you should be looking at how it is done in physically based renderers (read path tracers). What we do, is to sample the light and calculate the diffuse to each of the samples (well this can also be done for the previously mentioned way - calculating lambert N times is still really cheap). Specular lighting could use the same trick (although the mentioned reflection just looks better as unless you have a lot of samples - you will have a noise, which is a problem).


The real problem here are shadows, of course ray tracing is the ultimate answer here (yet, I assume your scene data are not in a way where ray tracing in realtime is possible) - so you have to stick with shadow maps. Actually omnidirectional shadow maps (cube shadow maps), as for me percentage-closer-soft-shadows (PCSS) worked really nice, again it is not physically correct (but you can get quite close by modifying it) achieving nice and plausible shadows for the objects. Other than that I've seen some guys having really good soft shadows using shadow volumes approach and penumbra wedges, but it was expensive as hell even for less complex scenes.






This is a interactively path traced scene (at around 30-50 spp per second on GPU) with area light. Note the shadows (those are with "caustics" here (not that powerful as the material is not clear and IoR is not high enough)). Yet, you should be able to see that even for quite small light the shadows are fully blurred for the parts that are closer to the light, which is a problem for technically any fast shadow map algorithm these days.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this