0

I recently added deferred shading into my engine, and ran across a technique called "light volumes". While being great because it reduces lighting computations to the minimum (executing only fragments in the light volume), I cannot figure out how I could render the rest of the scene with ambient lighting!

I get the following scene without ambient lighting: (the light volume has been highlighted in gray)

enter image description here

Of course, I could always render a fullscreen quad, but I would loose the benefit of this technique.

Any suggestions?

Edit : I finally got it to work thanks to Nicol : ) Here is a new picture :

enter image description here

Coder32
  • 181
  • 1
  • 10
  • 1
    Nicol's answer is correct but perhaps you could elaborate on why you think that an iteration through every pixel kills the benefit of deferred rendering for an ambient light source? You're still considering only those pixels that will actually be on screen, not any intermediate results that are subsequently overwritten as if you were doing it in the original renderer. – Tommy Dec 06 '15 at 21:58
  • I actually meant that rendering point lights as fullscreen quads was a waste of performance... because you don't need to pass through parts that are not lit by the light ! – Coder32 Dec 06 '15 at 22:05

1 Answers1

3

You do the ambient lighting in a separate pass. Just like you do with lights in general with deferred rendering. That is the general idea, that each light happens in its own pass, with you accumulating the results into the framebuffer by doing additive blending with them.

The ambient light is simply considered another lightsource.

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
  • Yes, I tried to do that but there is one problem : first I rendered the entire scene with the ambient light, and then rendered the point lights : you actually get this : http://stackoverflow.com/questions/34121885/deferred-shading-and-attenuation – Coder32 Dec 06 '15 at 22:00
  • When rendering point lights, it actually adds lighting on top, so you can see a difference at the edge of the light volume and the rest of the scene ! – Coder32 Dec 06 '15 at 22:03
  • @Coder32: Right, but that's not your problem above. Your problem above is that you aren't making that second ambient pass. If you do, then you get ambient lighting. The issue of the point lighting+light volume effect not being what you wanted is a separate question, one you already asked apparently. – Nicol Bolas Dec 07 '15 at 00:27
  • One more thing : do you have any suggestions on how to deal with those "sort of " circles in the attenuation of the light : making it the attenuation more smooth ? (You can see it in image 2 by zooming on it) – Coder32 Dec 07 '15 at 17:02