Hi Arts and have a happy new year
Ok so I have decided to make a simple stand alone application to test what you
said : create a new camera as a child of the main camera, the child camera will
be the FBO camera for the PPU processor
here is a part of my code :
Code:
void buildPPUScene(osg::Group* root, osg::Camera* camera)
{
setupFBOCamera(camera);
// create PPU
osgPPU::Processor* postProcessor = new osgPPU::Processor();
root->addChild(postProcessor);
// initialize the post process
postProcessor->setCamera(camera);
postProcessor->setName("Processor");
postProcessor->dirtyUnitSubgraph();
//
osgPPU::UnitBypass* bypass = new osgPPU::UnitBypass();
bypass->setName("HDRBypass");
postProcessor->addChild(bypass);
// just a resample example
osgPPU::UnitInResampleOut* resample = new osgPPU::UnitInResampleOut();
resample->setName("Resample");
resample->setInputTextureIndexForViewportReference(-1); // need this
here to get viewport from camera
resample->setFactorX(0.1);
resample->setFactorY(0.1);
bypass->addChild(resample);
//
osgPPU::UnitOut* ppuout = new osgPPU::UnitOut();
ppuout->setName("PipelineResult");
ppuout->setInputTextureIndexForViewportReference(-1); // need this here
to get viewport from camera
resample->addChild(ppuout);
}
int _tmain(int argc, _TCHAR* argv[])
{
osgViewer::Viewer viewer;
osg::Group* root = new osg::Group;
// get main camera
osg::Camera* camera = viewer.getCamera();
// read node
osg::Node* node = osgDB::readNodeFile("cow.osg");
// create child camera
osg::Camera* ppuCamera = new osg::Camera;
// add new camera as main camera child
camera->addChild(ppuCamera);
// init viewports
initCameraViewport(camera, 400, 400);
initCameraViewport(ppuCamera, 400, 400);
// build PPU resample scene
buildPPUScene(root, ppuCamera);
// add readed node as new camera child
ppuCamera->addChild(node);
viewer.setSceneData(root);
viewer.realize();
return viewer.run();
}
The setupFBOCamera function is the same as your setupCamera function present in
your osgppu_viewer example : it creates renderTexture, attaches it to the
camera in parameter and sets the camera to render into a FBO.
If I do not create the ppuCamera, it works well, I have my resample cow (in
this case the cow node is a child of the root).
But with the new ppuCamera, I have a black screen, as if no nodes are rendered;
that is strange because the cow node is a child of the new ppu camera, and it
should be rendered... no ?
So what do I make wrong ?
Thank you!
Cheers,
Sebastien
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=22223#22223
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org