[osg-users] Multi-pass rendering in OSG

Thrall, Bryan bryan.thrall at flightsafety.com
Wed Sep 17 07:38:25 PDT 2008


I'm attempting to implement a multiple pass rendering algorithm in OSG,
but I'm not sure what the best way is. I am just learning how to do this
and how to use Frame Buffer Objects. I initially tried to implement an
osgFX::Effect, since it supports multiple passes transparently. The
problem is how to pass the data between the passes.

The algorithm is to render the model to a texture, then process that
texture over 3 passes and composite it back into the scene. I used the
osgprerender example to do the first part using
osg::Camera::FRAME_BUFFER_OBJECT without problems. I then tried to use
osg::FrameBufferObject to pass the data from the first processing pass
to the second, but it doesn't work. It looks, from
osgUtil::RenderStage's Camera support, like osg::FrameBufferObject can't
be used simply by adding it to a StateSet, but it needs
glCheckFrameBufferStatusEXT after the apply(). Is this a limitation of
osg::FrameBufferObject, or am I missing something?

My current attempt is to use nested osg::Cameras with
osg::Camera::POST_RENDER for each pass, like so (hoping the ASCII art
turns out...):

Root
|->Camera(PRE_RENDER)
||->Model
|->Camera(POST_RENDER)
||->Pass 1 quad
||->Camera(POST_RENDER)
|||->Pass 2 quad
|||->Camera(POST_RENDER)
||||->Pass 3 quad
||||->Camera(POST_RENDER)
|||||->Final pass quad

At each pass, the texture target from the Camera's FBO is used to
texture the quad for the next pass (with shaders attached to the next
pass's StateSet to do the processing).

Is this a recommended approach? Are there any requirements on the
Cameras (Transform values, ABSOLUTE_RF, etc.) I should be configuring?

Thanks,
--
Bryan Thrall
FlightSafety International
bryan.thrall at flightsafety.com
 



More information about the osg-users mailing list