[osg-users] How do cameras handle the render target?

Werner Modenbach Werner.Modenbach at texion.eu
Wed Mar 15 04:56:37 PDT 2017

Hi Sebastion,

thanks for the quick reply.
What do you mean by composing to the same FBO? As i wrote attaching the
FBO to the child cameras the same way as with the main camera just 
delivers a black fbImage.

Concerning the screen capture example:
I remember an easier version where a slave camera was created with a 
pbuffer context and then
an image attached like thgat:






This seams more convenient than fiddling with gl functions.
I still have that version but it also shows only the rendered model.
Is it possible that the rendering is just not completed after the 
viewer->frame() call?
Is it necessary having a finalDrawCallback instead?

Thanks again

- Werner -

Am 15.03.2017 um 11:28 schrieb Sebastian Messerschmidt:
> Hi Werner,
> from diagonal reading:
> You could make all cameras composing to the same FBO and get the 
> texture in a final pass that can either put the image to Framebuffer 
> or read back the texture. Also take a look at the screenshot example 
> (using pbuffer) and the various draw callbacks.
> Cheers
> Sebastian
>> Hi all.
>> I have a problem understanding how cameras handle render targets.
>> My special case:
>> I have a standard camera on a view.
>> The root node of the scene is a group with the following children:
>> - my model
>> - hud camera for wallpaper
>> - hud camera for text
>> - more cameras for special cases
>> All the cameras are children of the group node and do POST_RENDER 
>> operation.
>> I need snapshots of the complete scene from various camera positions.
>> What I do:
>> osg::ref_ptr<osg::Camera>camera=view->getCamera();
>> osg::ref_ptr<osg::Image>fbImage=newosg::Image;
>> fbImage->allocateImage(width,height,1,GL_RGBA,GL_UNSIGNED_BYTE,1);
>> osg::Camera::RenderTargetImplementationrti=camera->getRenderTargetImplementation(); 
>> camera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);
>> camera->attach(osg::Camera::COLOR_BUFFER,fbImage.get(),0,0);
>> camera->dirtyAttachmentMap();
>> Then I do snapshots with the modified projection matrix of the camera.
>> After each snapshot I read the contents of the fbImage.
>> I reset everything to the initial status by:
>> camera->setRenderTargetImplementation(rti);
>> camera->detach(osg::Camera::COLOR_BUFFER);
>> camera->dirtyAttachmentMap();
>> Unfortunately the fbImage always only contains my model but not the
>> child cameras renderings.
>> Attaching the fbImage to the child cameras as well gives me just a black
>> fbImage.
>> Of course the child cameras do not clear the color buffer.
>> What is the proper way of receiving the complete rendering? I also tried
>> already
>> installing a slave camera to the main camera but that also gives me only
>> the rendered model.
>> And rendering to the fbImage by installing an additional child camera
>> with POST_RENDER instead
>> of a slave camera leads to the same result.
>> Rendering to screen is perfect, but to fbImage is not.
>> It seems I'm blind on some basic functionality and all my research
>> doesn't open my eyes.
>> I instantly hope for some help.
>> Thanks
>> - Werner -
>> _______________________________________________
>> osg-users mailing list
>> osg-users at lists.openscenegraph.org
>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org 
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

*TEXION Software Solutions, Rotter Bruch 26a, D-52068 Aachen*
Phone: +49 241 475757-0
Fax: +49 241 475757-29
Web: http://texion.eu
eMail: info at texion.eu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20170315/b90ca9f8/attachment-0003.htm>

More information about the osg-users mailing list