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!
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.
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
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.
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.
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!