View Full Version : Single-pass render to cubemap
I continue to stumble upon rants that with geometry shaders single-pass rendering to cubemaps becomes possible.
Question is: how exactly?
I know the EXT_texture_array extension, and that a cubemap can be interpreted as an array with 6 layers. But:
1) How do I bind this to the FBO? So far I found only functions for binding specific layers. How can I bind the *array* to the FBO?
2) I suppose in the GS an index can be estimated (to determine which face to render on) and sent to the VS, and subsequently to the FS. Anyone knows details about this?
06-26-2007, 07:49 AM
It's in the geometry shader extension spec, in the section "Layered Rendering" ;)
1) How do I bind this to the FBO? So far I found only functions for binding specific layers. How can I bind the *array* to the FBO?You just attach a cube map texture to the FBO. This texture has 6 layers, each of them may be rendered to. The functions for doing so are defined in the geometry shader extension spec, the original FBO spec allowed only single faces to be attached...
2) I suppose in the GS an index can be estimated (to determine which face to render on) and sent to the VS, and subsequently to the FS. Anyone knows details about this?When emitting a primitive in the geometry shader, you can write the gl_Layer builtin output variable to determine into which layer the primitive is rendered. In case of a cube map, this would be one of these values:
layer number cube map face
5 TEXTURE_CUBE_MAP_NEGATIVE_Z(copied from the spec)
06-26-2007, 07:52 AM
I have "only" 7800GT, so no practical knowledge about geometry shaders, but from the specs I think you should look for:
FramebuferTextureFace and gl_Layer (in GLSL)
This should put you on the right track.
There is still a question of writting proper geometry shader. The key is to determine which layers should a polygon be rendered to (you don't have to do any clipping but you'll have to produce duplicate of a polygon). A polygon can be visible on cubemap's face even if it doesn't have any vertices there.
A polygon should be visible on cubemap's face if it has at least one vertex on that face or if any ray casted through 4 corners of that cubemap face hits this polygon.
Edit: Seems like Overmind lapped me down at lap 42. Back to pits. I need to work on my setup. ;)
The geometry shader spec. Ah! I only looked into the FBO and texture array specs. *doh* :)
Thanks for the info!
05-02-2008, 11:27 PM
Has anyone conducted speed tests and gotten results to compare between single-pass and 6-pass rendering? I want to believe single-pass will be much faster, but does anyone have actual numbers?
05-02-2008, 11:45 PM
I read (http://developer.download.nvidia.com/presentations/2007/gdc/G80-OpenGL.pdf) (slide 38) that it wasn't faster to perform a single pass.
Also, how would one achieve multisampling when rendering in a single pass? I can't find anything about layered multisampled renderbuffer attachments...
05-03-2008, 12:06 AM
Of course there won't be any saving on the GPU. The question is whether there will be any savings on the CPU and any state changes the GPU might make, and whether that savings will overcome the performance lost by not doing frustum culling on each pass.
Multisampling is not a concern. I am only looking at this for shadowmap rendering.
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.