I am using shadow-mapping to add shadows to my world.

Currently, I use one lightsource, which means I have to draw my world twice: once in the lightview, once in the camera view.

I want to add more light sources to the world, I want at least 2 sources, maybe 3 or 4.

My world geometry is large, roughly 1M triangles, so drawing them comes at a large cost.

Are there any shortcuts I can take to avoid drawing the geometry for every light source?

Would it be possible to write to multiple depth textures in a single pass? E.g. pass several lightview matrices to a vertex shader and somehow write several framebuffers in one go?

I am using OpenGL core profile.

What I've tried: I looked at Multiple Render Targets, but it seems that every attached buffer will share the same vertex transformation, which would not help in my situation: every light view has a different transformation.

  • \$\begingroup\$ It sounds like you're describing a technique similar to the "single pass stereo rendering" approach often used in VR. The downside to what you suggest is that you'd have to submit the same models to multiple lights - even if the models illuminated by two lights are completely disjoint sets. If your shadow-casting lights are often "local", then you might gain more by culling the models to send to each light separately. That's less of a concern in VR since the two perspectives are necessarily very close together and mostly-overlapping. \$\endgroup\$ – DMGregory Aug 20 at 16:03
  • \$\begingroup\$ I looked that up, but that technique is merely a scenegraph optimization, not a render optimization: it still doubles the drawcalls, and doubles the vertex shader invokations. Unity uses it to share the cost of culling. docs.unity3d.com/Manual/SinglePassStereoRendering.html \$\endgroup\$ – Bram Aug 20 at 16:14
  • \$\begingroup\$ I think true single-pass versions can be accomplished with geometry shaders, but I'm not convinced they'd be a win for your application. \$\endgroup\$ – DMGregory Aug 20 at 16:18
  • \$\begingroup\$ When you have 1B triangles, maybe it's time to look into better world-partitioning algorithms (frustum culling, quad-trees, LODs, etc.) \$\endgroup\$ – Kromster Sep 5 at 5:33
  • \$\begingroup\$ @Kromster, oops. I messed up the units, it is actually 1M triangles. (From a 1B voxel field.) \$\endgroup\$ – Bram Sep 8 at 16:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.