View Full Version : Rendering texture atlas
09-03-2007, 04:32 PM
I want to create a texture atlas to which I render my scene from four different points of view, where a single mesh can only be in one view. This is working without poblems using glViewport for defining the the four quadrants of the renderable texture target but the downside is that I need four passes. I would like to select the quadrant to which I render the object in the shader. Is it possible to modify the projection matrix so that I can select the quadrant thus emulating the effect of the glViewport call?
Thanks in advance!
09-03-2007, 05:34 PM
Originally posted by LaBasX2:
Is it possible to modify the projection matrix so that I can select the quadrant thus emulating the effect of the glViewport call?I guess, but it really doesn't matter since you still need 4 passes, maybe if you put it though a geometry shader that made 4 copies of the polygons but in different places.
But it would possibly be really redundant and slower compared to the original method.
09-04-2007, 03:05 AM
You could use GL_NV_geometry_program4 extension and its layered framebuffers. It does not, however, support texture atlases, only 3D, cube and array textures.
09-04-2007, 06:33 AM
You can use a vertex attribute to specify which part of the atlas the should an object be rendered to, then adjust the position in the vertex shader according to this value. Yous should probably read the parts of specification about the projection matrix and device coordinates, I never really looked at it, so I can't post any code.
P.S. Cool, 1111 post :) I should never post again :D
09-04-2007, 10:19 AM
Originally posted by Zengar:
You can use a vertex attribute to specify which part of the atlas the should an object be rendered to, then adjust the position in the vertex shader according to this value.The problem is I don't know how to modify the projection matrix or the final gl_Position vector. I have tried a plenty of things like multiplying xyz with 0.5 and have also read a plenty of documents about the geometry pipeline but nothing works. Currently I'm not quite sure if it is possible at all since the hardware is doing some steps after the vertex shader execution like clipping and perspective divide. Any ideas? My intention for this texture atlas is to use it for cascaded shadow maps rendering the four splits in one pass.
09-04-2007, 11:27 AM
Is it really that important to do it in one pass? If you're doing the four passes correctly to begin with, the gain in using a one-pass approach should be negligible. There really isn't much overhead.
09-05-2007, 03:24 AM
Hi! I don't know if this is possible but supposing you're using framebuffer objects, can't you bind the same texture but at a different origin at different colorbuffer binding points, then output in each of them in a fragment program according to some bvec4 you set in the geometry shader(I really don't know if this will work...Just thinking aloud)? Then you won't have to modify vertex positions.
09-10-2007, 01:02 AM
Binding the same texture several times doesn't work. So probably I will have to stay with a multipass approach which hopefully really isn't that bad when well optimized.
Thanks for your help!
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.