Hi, does anyone know if it is possible to setup a pipeline such that I may turn on and turn off a blurring effect during runtime?
For example: camera->setViewport(new osg::Viewport(0,0,windowWidth,windowHeight)); camera->attach(osg::Camera::COLOR_BUFFER0, textureView); camera->setRenderTargetImplementation(renderImplementation); // setup osgPPU pipeline processor, which will use the main camera osg::ref_ptr<osgPPU::Processor> processor = new osgPPU::Processor(); p_ppuProcessor = processor; processor->setCamera(camera); // setup unit which will bring the output of the MAIN camera, // w/in the Processor unit into the pipeline osgPPU::UnitCameraAttachmentBypass* ucaByPass = new osgPPU::UnitCameraAttachmentBypass(); ucaByPass->setBufferComponent(osg::Camera::COLOR_BUFFER0); ucaByPass->setName("mainCamOutputTexUCAB"); processor->addChild(ucaByPass); // bypass With Blurring // osgPPU::UnitBypass* bypassWithBlurring = new osgPPU::UnitBypass(); bypassWithBlurring->setName("BypassWBlurring"); ucaByPass->addChild(bypassWithBlurring); // bypass withOUT blurring osgPPU::UnitBypass* bypassWOBlurring = new osgPPU::UnitBypass(); bypassWOBlurring->setName("BypassWOBlurring"); ucaByPass->addChild(bypassWOBlurring); .... blurring ppu code... .... osgPPU::UnitOut* unitOut2= new osgPPU::UnitOut(); osgPPU::ShaderAttribute* shaderAttribute= new osgPPU::ShaderAttribute(); { osg::Shader* shader= new osg::Shader(osg::Shader::FRAGMENT); const char* shaderSource= "uniform sampler2D textureNameInShader;\n" "void main()\n" "{\n" " gl_FragColor=texture2D(textureNameInShader,gl_TexCoord[0].st);\n" "}"; shader->setShaderSource(shaderSource); shaderAttribute->addShader(shader); shaderAttribute->setName("nomShaderAttribute"); shaderAttribute->add("textureNameInShader", osg::Uniform::SAMPLER_2D); shaderAttribute->set("textureNameInShader", 0); unitOut2->setName("finalOutputUnit"); unitOut2->setViewport(new osg::Viewport(0,0, windowWidth, windowHeight) ); unitOut2->getOrCreateStateSet()->setAttributeAndModes(shaderAttribute); } //exp 1 for blurring whole scene; bypassWithBlurring->addChild(blurx); blurx->addChild(blury); blury->addChild(unitOut2); bypassWOBlurring->addChild(unitOut2); How may I turn on and off my blur effect during runtime? I have tried using setActive but unfortunately, it only appears to work - within my pipeline - when applied to the last ppu, blury, and I get a black screen. Using removeChild() in any situation causes a runtime crash. I am not sure if removing a unit from processor is the right path to go either, because my units are children of other units and that would force me to re-construct my whole pipeline dynamically during runtime. I can do that but it is more work. Any help would be appreciated. Thank you! Cheers, Allen ------------------ Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=26595#26595 _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org