1

I'm making point lights with shadow maps, and currently I have it done with six depth map textures, each rendered individually and applied to the light map. This works quite well, but the performance cost is high.

Now, to improve the performance by reducing FBO changes and shader swapping between depthmap shader and lightmap shader, I was thinking of a couple of approaches. First one involves having a single texture, six times larger than the shadow map, and rendering all the point light depth maps "at once", and then using this texture to lay out the light map in one call. Is it possible to render only to portions of textures?

To elaborate the first example, it would be something like this:

1. Set shadow map size to 128x128
2. Create a depth map texture of 384x256 (3 x 2 shadow map)
3. Render the first 'side' of a point light to the rectangle (0, 0, 128, 128)
4. Render the second 'side' to the rectangle (128, 0, 128, 128)
5. - 9. Render the other 'sides' in a similar manner
10. Swap to light map mode
11. Render the light map in a single call using the 'cube-map'-ish depth texture

Second method I thought is to use 3D textures instead of partial rendering, but I still have a similar question: can I render to only a certain 'layer' of a 3D texture while retaining the other layers?

manabreak
  • 5,415
  • 7
  • 39
  • 96
  • 2
    What about actually using geometry shaders to do layered rendering? http://www.opengl.org/wiki/Geometry_Shader#Layered_rendering – Grimmy Jun 02 '13 at 07:33
  • @Grimmy That could work, but I try not to use GS for compatibility purposes. – manabreak Jun 02 '13 at 07:54
  • I don't know how much knowledge you have about shadow mapping and what quality the shadows should have. So i want to mention some techniques like _Cascaded Shadow Maps_, _Variance Shadow Maps_ and _Perspective Shadow Maps_ that you probably should take into account before you try to optimize. Because depending on the techniques you use you are _limited_ in what you can use to optimize. – t.niese Jun 02 '13 at 11:25
  • You can support both (GS and non-GS) version. When it comes to performance it is hard to say what you will gain from doing this. I've done way too many "obvious optimizations" in the past that lead to absolutely no gain. Maybe you are right that there is a faster way.. who knows.. :) – Grimmy Jun 02 '13 at 11:30

1 Answers1

2

Why would combined shadow maps have any advantage?

You have to render scene six times.

You could render 6 times 128x128 FBO and then create 256x384 texture and fill it with previously rendered textures. But bandwidth and sampling rate per-pixel remain exact same.

Rendering one part while preserving other's might be done with stencil buffer, but in this case I don't see any point of creating combined-shadow-map.

Hope this helps. Any feedback would be appreciated.

Dragan Okanovic
  • 7,509
  • 3
  • 32
  • 48