<p>Deferred rendering does not have an asymptic complexity of O(lights+fragments). It has a complexity of O(fragments+visibleFragments*lights).</p>

<p>What you are doing in deferred rendering is preventing having to calculate lighting for many fragments that cover the same screen pixel. Once you have found which ones are visible, all of those still have to calculate lighting from every light source.</p>

<p>This is faster than forward rendering on the premise that lighting calculations are heavier than geometry calculations and that most fragments are ocluded by other fragments.</p>

CC BY-SA 3.0
2018-02-27T05:25:25.383Z
Not necessarily. The main lights that cover the whole scene need to be done for each pixel, right enough. But the less-important lights that only affect a small local area can be rasterized as geometry, and a pixel shader run additively over just their area of effect. Good illustration of this technique used in GTA5 at http://www.adriancourreges.com/blog/2015/11/02/gta-v-graphics-study-part-2/  (last 2 slides)
russ
CC BY-SA 3.0
2018-02-27T05:30:40.267Z
@russ that is not really related to my answer or to the nature of deferred shading. What you propose is just a technique for LODing distant light sources
Sebastián Mestre
CC BY-SA 3.0
2018-02-27T07:08:59.060Z
Did you look at the last couple of slides where they're rendering the streetlamps and car lights at night? I'm not talking about the billboarding of distant light sources, rather the technique of rasterizing a sphere, cone, or whatever that covers a light's area of effect, and running an additive pixel shader only for the pixels it covers.
russ
CC BY-SA 3.0
2018-02-27T07:25:38.953Z
Seems the term I'm looking for is 'Light Volumes'. Better illustration here - http://www.spellcasterstudios.com/?p=339
russ
CC BY-SA 3.0
2018-02-27T07:29:20.873Z
@russ ah i see what you mean. I will edit my answer to touch on that subject later.
Sebastián Mestre
CC BY-SA 3.0
2018-02-23T00:32:40.353Z
2018-02-23T00:32:40.353Z
Sebastián Mestre
<p>Ok so I am trying to understand how to combine these 2 techniques and I am failing.</p>

<p>The main goal is to reach the O(lights+fragments) complexity of deferred rendering, instead of O(lights*fragments) of naive/forward rendering.</p>

<p>This is how I am currently doing things:</p>

<p>Say we have n lights. Then we generate n shadow maps O(n)</p>

<p>Now we do one render pass to generate the normal, diffuse color, depth.... information in the geometry buffers.</p>

<p>Then we check for every fragment whether it is occluded in ALL lights. and shadow it if it is.</p>

<p>This has an O(Lights*Fragments) complexity, which is wrong, so how can you reach the ideal asymptotic complexity? What should you do?</p>

<shadow><shading><shadow-mapping><deferred-rendering>
How to use shadow mapping and deferred rendering to create a large amount of lights?
Makogan
# How to use shadow mapping and deferred rendering to create a large amount of lights?

(Asked by: username_0 on 2018-02-22)

Ok so I am trying to understand how to combine these 2 techniques and I am failing.

The main goal is to reach the O(lights+fragments) complexity of deferred rendering, instead of O(lights\*fragments) of naive/forward rendering.

This is how I am currently doing things:

Say we have n lights. Then we generate n shadow maps O(n)

Now we do one render pass to generate the normal, diffuse color, depth.... information in the geometry buffers.

Then we check for every fragment whether it is occluded in ALL lights. and shadow it if it is.

This has an O(Lights\*Fragments) complexity, which is wrong, so how can you reach the ideal asymptotic complexity? What should you do?

**Tags:** shadow, shading, shadow-mapping, deferred-rendering


---

## 1 answers

### Answer by username_1 on 2018-02-23. Score: 2 | Accepted answer

Deferred rendering does not have an asymptic complexity of O(lights+fragments). It has a complexity of O(fragments+visibleFragments\*lights).

What you are doing in deferred rendering is preventing having to calculate lighting for many fragments that cover the same screen pixel. Once you have found which ones are visible, all of those still have to calculate lighting from every light source.

This is faster than forward rendering on the premise that lighting calculations are heavier than geometry calculations and that most fragments are ocluded by other fragments.

> **Comments:**
> **username_2**: Not necessarily. The main lights that cover the whole scene need to be done for each pixel, right enough. But the less-important lights that only affect a small local area can be rasterized as geometry, and a pixel shader run additively over just their area of effect. Good illustration of this technique used in GTA5 at http://www.adriancourreges.com/blog/2015/11/02/gta-v-graphics-study-part-2/  (last 2 slides)  
> **username_1**: @username_2 that is not really related to my answer or to the nature of deferred shading. What you propose is just a technique for LODing distant light sources  
> **username_2**: Did you look at the last couple of slides where they're rendering the streetlamps and car lights at night? I'm not talking about the billboarding of distant light sources, rather the technique of rasterizing a sphere, cone, or whatever that covers a light's area of effect, and running an additive pixel shader only for the pixels it covers.  
> **username_2**: Seems the term I'm looking for is 'Light Volumes'. Better illustration here - http://www.spellcasterstudios.com/?p=339  
> **username_1**: @username_2 ah i see what you mean. I will edit my answer to touch on that subject later.  

---

