From 898a313272674f66b362315999733cf051440dc4 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 27 Feb 2009 10:47:33 +0000 Subject: [PATCH] From Atr Tevs, first email: "in the current implementation of osgUtil::RenderStage::drawInner() method, there is some wrong assumptions made. The problem is, that whenever one does use multisampling functionality, the Blit operation (which suppose to copy the content of multisampled FBO into the usual one) doesn't perform well in some cases. I've attached a corrected version of the RenderStage. It do just add one line, which enables the multisampled FBO as a readable just before the usual FBO is set as writable. With these corrections the Blit operation performs now correct and allows using of multisampled rendering results further." second email: "There was a problem when blitting the multisampled FBO with internal formats. The default internal format of color buffered multisample FBO was GL_RGBA. This has converted the color values whenever the FBO content was copied. I've added couple of lines, which do just enable the multisampled FBO internal format in respect to the attached color texture's internal format. This makes it possible to blit even float valued texture, so make HDR with multisampling possible ;)" --- src/osgUtil/RenderStage.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/osgUtil/RenderStage.cpp b/src/osgUtil/RenderStage.cpp index 35686e7e3..d906e0280 100644 --- a/src/osgUtil/RenderStage.cpp +++ b/src/osgUtil/RenderStage.cpp @@ -391,8 +391,14 @@ void RenderStage::runCameraSetUp(osg::RenderInfo& renderInfo) case Camera::PACKED_DEPTH_STENCIL_BUFFER: internalFormat = GL_DEPTH_STENCIL_EXT; break; + + // all other buffers are color buffers default: - internalFormat = GL_RGBA; + // setup the internal format based on attached texture if such exists, otherwise just default format + if (attachment._texture) + internalFormat = attachment._texture->getInternalFormat(); + else + internalFormat = GL_RGBA; break; } } @@ -894,6 +900,7 @@ void RenderStage::drawInner(osg::RenderInfo& renderInfo,RenderLeaf*& previous, b } // Bind the resolve framebuffer to blit into. + _fbo->apply(state, FrameBufferObject::READ_FRAMEBUFFER); _resolveFbo->apply(state, FrameBufferObject::DRAW_FRAMEBUFFER); // Blit to the resolve framebuffer.