Hi Paul,

Thank You. I like your solution. I cannot test it now, will do it on monday and let you know how it went.

Cheers,
Wojtek Lewandowski

--------------------------------------------------
From: "Paul Martz" <[email protected]>
Sent: Saturday, October 24, 2009 10:22 PM
To: "OpenSceneGraph Users" <[email protected]>
Subject: Re: [osg-users] Improving multisampled FBO

Hi Wojtek and others --

I've posted a proposed change to osg-submissions. With my change, there is no longer a need for the #defines Wojtek had added to RenderStage.cpp to stop implicit creation of attachments. This is now under application control.

In my code, I've added a new Camera method, setUseBufferMask(), and there are three bits you can OR into the parameters. For example, if you wanted color and stencil but not depth, you'd call:
 camera->setUseBufferMask( osg::Camera::USE_COLOR_BUFFER |
    osg::Camera::USE_STENCIL_BUFFER );

If you don't use this entry point, then you get the old default behavior, which is the same as USE_COLOR_BUFFER|USE_DEPTH_BUFFER.

If you explicitly set your own attachment with attach() and then call setUseBufferMasks but leave the corresponding bit out, your attachment is not removed: The bit mask controls implicit creation of attachments only.

If you are doing MSFBO, you pass in two masks to control attachments to the multisampled FBO and the resolve FBO respectively. In my case, I was using MSFBO to render to texture, and I only needed to resolve color, not depth. So I can now call:
 camera->setUseBufferMask(
      // Buffers in FBO for multisampled rendering:
    osg::Camera::USE_COLOR_BUFFER | osg::Camera::USE_STENCIL_BUFFER,
      // Buffers in resolve FBO:
    osg::Camera::USE_COLOR_BUFFER );

This produces a color and depth attachment to the multisampled FBO, but only color (my texture map) in the resolve FBO. So OSG will no longer create and blit to an unnecessary resolve depth buffer.

I know this isn't the complete overhaul / explicit FBO interface we had both expressed a desire for, but I think it creates a minimum of disruption for the upcoming stable release and preserves backwards compatibility, which is important.

Please test if you can, and if there are better fixes or ways to improve this change, please suggest or submit them. Thanks.

Paul Martz
Skew Matrix Software LLC
_http://www.skew-matrix.com_ <http://www.skew-matrix.com/>
+1 303 859 9466

_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to