Re: [osg-users] [osgPPU] no results with osgPPU
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=3#3 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgPPU] no results with osgPPU
Hi Art, I will try to add a camera node as a child of the main camera. I will also try to disable the main camera callback Thank you! Cheers, Sebastien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=21492#21492 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgPPU] no results with osgPPU
Hi Art, thx for your answer Sure you can know what the host application is doing, and unfortunately neither am I ... But I am trying to understant what is modified by the application, that's why I need some help... I have check in debug mode the run time passes throught the Unit::traverse methode. So I guess osgPPU is not disable. I did what you suggest, and I have a black screen, like there was no root. I have one question about your graph, did you mean that the main camera node has 2 children : the osgPPU processor and the custom FBO camera with your graph ? I have set the FBO camera with RELATIVE_RF transform and I didnt set the view and projection matrices. I guess the view matrix will be update by its parent and osgPPU will set the projection matrix with a 2 projection. Am I right ? Thank you! Cheers, Sebastien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=21223#21223 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgPPU] no results with osgPPU
Hi Sebastian, seb wrote: I did what you suggest, and I have a black screen, like there was no root. I have one question about your graph, did you mean that the main camera node has 2 children : the osgPPU processor and the custom FBO camera with your graph ? Have you tried just to remove osgPPU completly and set the main camera's implementation to FBO. This should give you also black screen. Or did you tried to make the graph, I proposed to you? Yes, I mean that the main root node has two children. One is the slave camera and another one is the ppu's processor. The slave camera has to be used by the processor through setCamera(). Try it first in your application before going to the host application. I have set the FBO camera with RELATIVE_RF transform and I didnt set the view and projection matrices. I guess the view matrix will be update by its parent and osgPPU will set the projection matrix with a 2 projection. Am I right ? osgPPU didn't change anything within your camera, it just uses camera's texture as input nothing else. So you have to setup your projection matrices by your self. With RELATIVE_RF only the view matrix should be updated. art -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=21226#21226 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgPPU] no results with osgPPU
Hi Art, With the graph you propose, I have the back screen, I have checked and the scene graph is correct, I didn't forget to attach any nodes, so I do not understand. By modifying directly the main camera,I did it too, and I have the scene with no osgPPU (no resambled scene) like I explained on my 1st post. I have checked too in the debut mode, and the camera has still the FRAME_BUFFER_OBJECT mode on each frame. So I do not understand either. I see in debug mode that the main camera holds pre and post render callback, do you think these functions may interfer with osgPPU ? Well I really appreciate your help but I begin to think it is impossible to guess what the host application is doing without the code or any documentations. Sebastien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=21230#21230 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgPPU] no results with osgPPU
Hello, seb wrote: With the graph you propose, I have the back screen, I have checked and the scene graph is correct, I didn't forget to attach any nodes, so I do not understand. Try this first in your own application before going to the unknown thing. By modifying directly the main camera,I did it too, and I have the scene with no osgPPU (no resambled scene) like I explained on my 1st post. So that means that the host application do resetup the main camera settings. This is because you should actually don't see anything except of not-changed scene. this is becaus you set your camera to render into a texture and not on the screen. This means that whenever you want to try with the main camera, it will probably not work. Therefor try to setup a slave camera which render into the texture and use its texture for processing. Just like I said in previous posts. I have checked too in the debug mode, and the camera has still the FRAME_BUFFER_OBJECT mode on each frame. So I do not understand either. I see in debug mode that the main camera holds pre and post render callback, do you think these functions may interfer with osgPPU ? Hmm, that is somehow strange. If you camera renders into a texture by FBO, how you can see any output then on the screen without osgPPU or without anything which renders this texture on the screen. It could be that in the post render callback exactly this happens. If this is the case, then it might be that osgPPU will never work, or at least you will not see it's results on the screen. However I am not sure without knowing what is happening in those callbacks. So the only way I see how to include osgPPU into an OSG application where you do not know what this application is doing, is to use the scene graph I proposed earlier. Also to disable all extra render callbacks on the main camera or render stage. I hope, this help you somehow. art -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=21255#21255 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] [osgPPU] no results with osgPPU
Hi, In my application, I just add this code on the init part : Code: osg::ref_ptrosg::Texture2D texture = new osg::Texture2D; texture-setTextureSize(width, height); texture-setFilter(osg::Texture2D::MIN_FILTER, osg::Texture2D::LINEAR); texture-setFilter(osg::Texture2D::MAG_FILTER, osg::Texture2D::LINEAR); texture-setInternalFormat(GL_RGBA); m_camera-setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR); m_camera-setRenderTargetImplementation(osg::Camera::PIXEL_BUFFER_RTT); m_camera-attach(osg::Camera::COLOR_BUFFER, texture); osg::ref_ptrosgPPU::Processor postProcessor = new osgPPU::Processor(); postProcessor-setCamera(m_camera); postProcessor-setName(Processor); postProcessor-dirtyUnitSubgraph(); m_root-addChild(postProcessor.get()); osgPPU::UnitBypass* bypass = new osgPPU::UnitBypass(); bypass-setName(Bypass); postProcessor-addChild(bypass); osgPPU::UnitInResampleOut* resample = new osgPPU::UnitInResampleOut(); resample-setName(Resample); resample-setInputTextureIndexForViewportReference(-1); resample-setFactorX(0.1); resample-setFactorY(0.1); bypass-addChild(resample); osgPPU::UnitOut* ppuout = new osgPPU::UnitOut(); ppuout-setName(PipelineResult); ppuout-setInputTextureIndexForViewportReference(-1); resample-addChild(ppuout); the camera is the only one camera that I have, it is the view's camera. the root is the scene data I just want to do a post render to texture into resampled texture, but I just see the scene as there was no ppu (my image is not resampled) Do I miss something ? Cheers, Sebastien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=21150#21150 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgPPU] no results with osgPPU
Hi Sebastian, try to change the line: m_camera-setRenderTargetImplementation(osg::Camera::PIXEL_BUFFER_RTT); into: m_camera-setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT); I have never tried osgPPU together with pbuffers. Usualy it shouldn't be any problem, because osgPPU just do require the texture. However, when UnitOut is rendered it will render to FBO 0, so the default frame buffer. If your main camera is then set to use pbuffers, I assume then, that the result of the osgPPU will be overwritten by your camera. Not sure, just try it. cheers, art seb wrote: Hi, In my application, I just add this code on the init part : Code: osg::ref_ptrosg::Texture2D texture = new osg::Texture2D; texture-setTextureSize(width, height); texture-setFilter(osg::Texture2D::MIN_FILTER, osg::Texture2D::LINEAR); texture-setFilter(osg::Texture2D::MAG_FILTER, osg::Texture2D::LINEAR); texture-setInternalFormat(GL_RGBA); m_camera-setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR); m_camera-setRenderTargetImplementation(osg::Camera::PIXEL_BUFFER_RTT); m_camera-attach(osg::Camera::COLOR_BUFFER, texture); osg::ref_ptrosgPPU::Processor postProcessor = new osgPPU::Processor(); postProcessor-setCamera(m_camera); postProcessor-setName(Processor); postProcessor-dirtyUnitSubgraph(); m_root-addChild(postProcessor.get()); osgPPU::UnitBypass* bypass = new osgPPU::UnitBypass(); bypass-setName(Bypass); postProcessor-addChild(bypass); osgPPU::UnitInResampleOut* resample = new osgPPU::UnitInResampleOut(); resample-setName(Resample); resample-setInputTextureIndexForViewportReference(-1); resample-setFactorX(0.1); resample-setFactorY(0.1); bypass-addChild(resample); osgPPU::UnitOut* ppuout = new osgPPU::UnitOut(); ppuout-setName(PipelineResult); ppuout-setInputTextureIndexForViewportReference(-1); resample-addChild(ppuout); the camera is the only one camera that I have, it is the view's camera. the root is the scene data I just want to do a post render to texture into resampled texture, but I just see the scene as there was no ppu (my image is not resampled) Do I miss something ? Cheers, Sebastien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=21152#21152 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgPPU] no results with osgPPU
Hi, I tried with FRAME_BUFFER_OBJECT but I have the same result (ie no results ^^) But I think I have to explain my program context. In fact, I am developping a plugin for a closed application (I do not have the source of this application); within this plugin I have an access to the root scene graph, and I can get the camera with the static graphic context (getAllRegisteredGraphicsContexts) If I add my code to my own application, it works well. But if I add this code inside the closed application plugin, I do not have any results, as if osgPPU was disabled. Do you have any ideas of this behavior ? Maybe the closed application is resetting the camera each frame ? maybe a camera render callback disable osgPPU ? I really do not know, I do not have much experience with osgPPU and I need some ideas ... Thank you Cheers, Sebastien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=21159#21159 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgPPU] no results with osgPPU
Hi Sebastian, of course I can not know what the host application is doing. You can run the application with OSG_NOTIFY_LEVEL=debug. The osgPPU units will then print information about their execution on the console. So if you do not see there anything, then it might be that they are disable for some reasons. However they should be enabled, because from the host application point of view this are just another nodes in the scene graph. What happens if you just set the main camera to use frame buffer object and don't use osgPPU at all. You then should not see anything, because main camera will then render into the texture and not on the screen. If you then see your previous results, then it means that the settings of your main camera are restored to something default. The way to solve that will then be to define your own scene graph with another camera, which will render the scene into the texture. So something like this: Code: mainCamera | | yourCam(FBO) - osgPPU | scene Maybe you can try this. Cheers, art -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=21160#21160 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org