Hi,
Thank you Harash.

> 
> Another Way: The One you are using Keep a UnitInOut parallel to your blurring 
> channel. In the shader for his unit, just pass the Input to the output. 
> Connect the O/P of both to the UnitOut. Enable node mask of the preferred 
> channel as per requirement.  


Do you mean?

processor = new processor()
processor->setCamera(...);
ucabypass = new UnitCameraAttachmentBypass();
processor->addChild(ucabypass); // gets texture from Camera


// OUTPUT to the Screen
// setup output ppu unit that is the size of the scene and is a 
//  tex to be rendered to the screen w/in the FBO.
   osgPPU::UnitOut* unitOut2= new osgPPU::UnitOut(); 

Code:

   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); 
   } 




// non-blur channel
ucabypass->addChild(unitOut2);


// BLUR-CHANNEL

Code:

    osgPPU::UnitInOut* blurx = new osgPPU::UnitInOut();
    osgPPU::UnitInOut* blury = new osgPPU::UnitInOut();
    {
      // set name and indicies
      blurx->setName("BlurHorizontal");
      blury->setName("BlurVertical");

      // read shaders from file
      osg::ref_ptr<osgDB::ReaderWriter::Options> fragmentOptions = new 
osgDB::ReaderWriter::Options("fragment");
      osg::ref_ptr<osgDB::ReaderWriter::Options> vertexOptions = new 
osgDB::ReaderWriter::Options("vertex");
      osg::Shader* vshader = 
osgDB::readShaderFile("Data/glsl/gauss_convolution_vp.glsl", 
vertexOptions.get());
      osg::Shader* fhshader = 
osgDB::readShaderFile("Data/glsl/gauss_convolution_1Dx_fp.glsl", 
fragmentOptions.get());
      osg::Shader* fvshader = 
osgDB::readShaderFile("Data/glsl/gauss_convolution_1Dy_fp.glsl", 
fragmentOptions.get());

        if (!vshader || !fhshader || !fvshader)
        {
          printf("One of the shader files gauss_convolution_*.glsl wasn't 
found!\n");
        }

      // setup horizontal blur shaders
      osgPPU::ShaderAttribute* gaussx = new osgPPU::ShaderAttribute();
      gaussx->addShader(vshader);
      gaussx->addShader(fhshader);
      gaussx->setName("BlurHorizontalShader");

      gaussx->add("sigma", osg::Uniform::FLOAT);
      gaussx->add("radius", osg::Uniform::FLOAT);
      gaussx->add("texUnit0", osg::Uniform::SAMPLER_2D);

      gaussx->set("sigma", gBlurSigma2);
      gaussx->set("radius", gBlurRadius2);
      gaussx->set("texUnit0", 0);

      blurx->getOrCreateStateSet()->setAttributeAndModes(gaussx);

      // setup vertical blur shaders
      osgPPU::ShaderAttribute* gaussy = new osgPPU::ShaderAttribute();
      gaussy->addShader(vshader);
      gaussy->addShader(fvshader);
      gaussy->setName("BlurVerticalShader");

      gaussy->add("sigma", osg::Uniform::FLOAT);
      gaussy->add("radius", osg::Uniform::FLOAT);
      gaussy->add("texUnit0", osg::Uniform::SAMPLER_2D);

      gaussy->set("sigma", gBlurSigma2);
      gaussy->set("radius", gBlurRadius2);
      gaussy->set("texUnit0", 0);

      blury->getOrCreateStateSet()->setAttributeAndModes(gaussy);
    }




   ucabypass->addChild(blurx);
   blurx->addChild(blury);
   blury->addChild(unitOut2);


Now I have 2 inputs to unitOut2.  How would I enable a "node" mask?  I have 
never heard of such a thing.


Thank you!

Cheers,
Allen

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=26598#26598





_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to