<div dir="ltr">Oh darn!  I had a good reply to this :)   Congrat's on the find!<br><br>On Thursday, December 12, 2019 at 12:51:02 AM UTC-8, Philipp Wagner wrote:<blockquote class="gmail_quote" style="margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir="ltr">Sorry, the issue has been that the camera automatically adjusted the near and far plane when rendering the individual parts.<div>Problem solved.</div><div><br></div><div>Grettings,</div><div>Phil<br><br>Am Dienstag, 10. Dezember 2019 16:42:23 UTC+1 schrieb Philipp Wagner:<blockquote class="gmail_quote" style="margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><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(<wbr>context);<br>
    <br>
    osg::ref_ptr<osg::Image> img = new osg::Image;<br>
    img->allocateImage(<wbr>textureWidth, textureHeight, 1, GL_RGBA,
    GL_UNSIGNED_BYTE);<br>
    camera->attach(osg::Camera::<wbr>COLOR_BUFFER0, img, numSamples);<br>
    camera->attach(osg::Camera::<wbr>DEPTH_BUFFER, GL_DEPTH_COMPONENT32);<br>
    camera->setRenderOrder(osg::<wbr>Camera::PRE_RENDER);<br>
camera-><wbr>setRenderTargetImplementation(<wbr>osg::Camera::<wbr>RenderTargetImplementation::<wbr>FRAME_BUFFER_OBJECT);<br>
    camera->setReferenceFrame(osg:<wbr>:Camera::ABSOLUTE_RF);<br>
    camera-><wbr>setProjectionResizePolicy(osg:<wbr>:Camera::FIXED);<br>
    camera->setViewport(0, 0, img->s(), img->t());<br>
    viewer->addSlave(camera);<br>
    <br>
    camera->setClearMask(GL_DEPTH_<wbr>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></blockquote></div></div></blockquote></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/0ac99069-ec02-4af0-9f17-77743dcc871b%40googlegroups.com?utm_medium=email&utm_source=footer">https://groups.google.com/d/msgid/osg-users/0ac99069-ec02-4af0-9f17-77743dcc871b%40googlegroups.com</a>.<br />