Rendering to different locations in texture


For purposes of shading (and shadow mapping in this case) I need to pass multiple shadow maps to a shader. Using many texture slots can quickly drain all the available resources, so I guessed it’s much better to pass one, bigger texture that would contain all the shadow maps layed after eachother in a rectangles let’s say 800x600.
So here comes my question: how to dynamically change viewport for rendering to texture? Something like shifting the viewport’s X and Width values for some constant value.

I’ve read about that geometry shader can do something like this, but isn’t it an overkill? I have the whole scene, I got the texture, and using a whole additional shader stage just to change viewport seemed a bit overcomplicated to me.

Use texture arrays as a primary, or texture atlases (as you allude to) as a fallback plan. See this thread. You can do a pass per shadow map, or one pass for all maps. If you chose the latter (layered rendering), see the wiki for info on having separate viewports per layer.

So basically I can use glFramebufferTextureLayer with texture array, right? I didn’t know theese two can be combined. I guess that solves my problems. Thank you for pointing me at right direction!

Yes, if you want to use layered rendering.