1

I have question about usage of multiple shadowmaps in deferred shading. I have implemented a single shadowmap in forward shading. In forward rendering, in the vertex shader of each object I calculated it's position in lightspace and compared it to the shadowmap in the fragment shader. I can see that working with multiple maps with an array of projection matrices and an array of shadowmaps as uniforms.

In the case of deferred shading I was wondering what is the common practice. The way I see it there are a few options:

  1. In the deferred shading, for each pixel I calculate it's position in each lightspace and compare it to the corresponding lightmap. (that way I do the calculation for each fragment and each matrix which might too be expensive?)

  2. In forward rendering I calculate the position of each vertex in each projection and there is a G-buffer output for each position. I then do the comparison in the deferred shading. (that way I do the computation of the position only once per vertex instead of once per pixel but I have a shadowmap and lightspace position for each shadow which seems suboptimal)

  3. A bit like 2. But I do the verification in forward rendering. That way I can store many booleans if it's in the light or not for each shadow in one int texture. The problem is that I can't do soft shadows that way.

  4. Maybe something better?

To synthesise: 1 needs many matrices multipication but is easy to implement. 2 needs few matrices multiplication but many textures and outputs (which is limited by the graphic card). and 3 needs few output and few calculations per pixel. But I can't' get soft shadows because the result is an array of boolean.

I am not doing it really for better performance but mostly to learn new stuffs. I'm open to suggestions. Maybe I'm misunderstanding something. Is there a standard way to do it?

florent teppe
  • 529
  • 5
  • 13
  • There's a good thread on this subject here: https://gamedev.stackexchange.com/questions/25436/shadows-in-deferred-rendering – Varrak May 15 '18 at 18:23
  • @SteveSmith I'm not too sure about the first answer, I don't quite get what he means, but the second answer seems to indicate (1) as a viable option. I also realized that (1) works way better with parralax mapping. – florent teppe May 15 '18 at 18:57

0 Answers0