PDA

View Full Version : Rendering to different locations in texture



overTaker
02-25-2014, 06:42 AM
Hello.

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.

Dark Photon
02-25-2014, 07:21 AM
Use texture arrays as a primary, or texture atlases (as you allude to) as a fallback plan. See this thread (http://www.opengl.org/discussion_boards/showthread.php/183692-Cascaded-shadow-mapping-and-GL_TEXTURE_2D_ARRAY). You can do a pass per shadow map, or one pass for all maps. If you chose the latter (layered rendering), see the wiki (http://www.opengl.org/wiki/Geometry_Shader#Layered_rendering) for info on having separate viewports per layer.

overTaker
02-25-2014, 09:51 AM
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!

Dark Photon
02-28-2014, 02:36 PM
Yes, if you want to use layered rendering.