<div dir="ltr">Hi,<br>
<br>
I want to perform an offscreen rendering of a scene that is too
large to fit into the GPU memory at once (lots of big textures).<br>
My idea was to render parts of the scene each in its own frame, and
disable the clearing of the depth and color buffer.<br>
This does work for the color buffer, but the depth buffer seems to
be cleared after each frame, which leads to incorrect results (The
later parts are drawn over the previous ones, even though they are
behind the other parts).<br>
<br>
The algorithm:<br>
1. Create camera/context/...<br>
2. Clear the buffers (i.e. Render an empty scene with a clear mask
of (GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT)<br>
3. Disable buffer clearing<br>
4. Render each part in its own frame<br>
a. Add part to the scene<br>
b. Render<br>
c. Remove part from the scene<br>
5. Read back color buffer<br><br><br>
osg::ref_ptr<::osg::Camera> camera = new osg::Camera();<br>
<br>
//Here we set the camera orientation/projection matrix<br>
<br>
camera->setClearColor(...);<br>
camera->setGraphicsContext(context);<br>
<br>
osg::ref_ptr<osg::Image> img = new osg::Image;<br>
img->allocateImage(textureWidth, textureHeight, 1, GL_RGBA,
GL_UNSIGNED_BYTE);<br>
camera->attach(osg::Camera::COLOR_BUFFER0, img, numSamples);<br>
camera->attach(osg::Camera::DEPTH_BUFFER, GL_DEPTH_COMPONENT32);<br>
camera->setRenderOrder(osg::Camera::PRE_RENDER);<br>
camera->setRenderTargetImplementation(osg::Camera::RenderTargetImplementation::FRAME_BUFFER_OBJECT);<br>
camera->setReferenceFrame(osg::Camera::ABSOLUTE_RF);<br>
camera->setProjectionResizePolicy(osg::Camera::FIXED);<br>
camera->setViewport(0, 0, img->s(), img->t());<br>
viewer->addSlave(camera);<br>
<br>
camera->setClearMask(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);<br>
viewer->frame();<br>
camera->setClearMask(0);<br>
for (auto& item : parts)<br>
{<br>
//Here we create and add the item to the scene...<br>
viewer->frame();<br>
//Here we remove item from the scene and delete it<br>
}<br><div><br></div><div>Thanks in advance</div><div>Phil</div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups "OpenSceneGraph Users" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="mailto:osg-users+unsubscribe@googlegroups.com">osg-users+unsubscribe@googlegroups.com</a>.<br />
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/osg-users/c6f7907d-6c89-4c00-973c-f9dc0585ae32%40googlegroups.com?utm_medium=email&utm_source=footer">https://groups.google.com/d/msgid/osg-users/c6f7907d-6c89-4c00-973c-f9dc0585ae32%40googlegroups.com</a>.<br />