[osg-users] How do cameras handle the render target?
Werner Modenbach
Werner.Modenbach at texion.eu
Wed Mar 15 02:56:35 PDT 2017
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 -
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20170315/aee880eb/attachment-0002.htm>
More information about the osg-users
mailing list