Hi art,

Thank you for your answer.
I did not success in installing the necessary plug-in to make a .ppu file.

To answer to your question about the processor: it is a child of the root 
osg::Group and so is my quad.

Since yesterday I minimalized my code and I have something "working".

Actually, it's not doing anything.
It's supposed to pass through 4 units...

UnitTexture->UnitInOut->UnitInOut->UnitInOut

... which does nothing!

I tried with a fifth unit UnitOut like in some examples but it changes nothing 
except that for any :
-setInputTextureIndexForViewportReference(-1)
-or setInputTextureIndexForViewportReference(0)

.. I get a black screen.

For the first UnitInOut I wrote: setInputTextureIndexForViewportReference(-1);
otherwise it crashes

I set the others to 0.

Can someone help me to get rid of these viewports?
Because I just try to pass computed textures from a shader to another for the 
moment.

Thanks in advance  :-* 

Here is a part of the code I wrote:


Code:

osgPPU::UnitTexture* textureUnit = new osgPPU::UnitTexture(greenTexture);
        osgPPU::UnitInOut* greenUnit = new osgPPU::UnitInOut();
        osgPPU::UnitInOut* redUnit = new osgPPU::UnitInOut();
        osgPPU::UnitInOut* blueUnit = new osgPPU::UnitInOut();

        // Green Shader Attribute

        osgPPU::ShaderAttribute* greenSA = new osgPPU::ShaderAttribute();

        osg::Shader* greenVS = new osg::Shader(osg::Shader::VERTEX);
        greenVS = osgDB::readShaderFile("Data/glsl/green.vert");
    osg::Shader* greenFS = new osg::Shader(osg::Shader::FRAGMENT);
        greenFS = osgDB::readShaderFile("Data/glsl/green.frag");

    greenSA->setName("greenSA");
        greenSA->add("textureBase2D", osg::Uniform::SAMPLER_2D);
        greenSA->set("textureBase2D", 0);

        greenSA->addShader(greenVS);
    greenSA->addShader(greenFS);

        // Green Unit
        greenUnit->getOrCreateStateSet()->setAttributeAndModes(greenSA);
        greenUnit->setName("greenUnit");
    // we have to setup the viewport of the InOut unit, because the texture size
    // is not defined until the first frame is completly run through
        greenUnit->setInputTextureIndexForViewportReference(-1);
        greenUnit->setViewport(new osg::Viewport(0,0, monImage->s(), 
monImage->t()));
        greenUnit->setInputToUniform(textureUnit,"textureBase2D",true);
        gUnitTexture = greenUnit->getOrCreateOutputTexture(-1);

                // Red Shader Attribute

        osgPPU::ShaderAttribute* redSA = new osgPPU::ShaderAttribute();
        osg::Shader* redVS = osgDB::readShaderFile("Data/glsl/red.vert");
        osg::Shader* redFS = osgDB::readShaderFile("Data/glsl/red.frag");

        redSA->addShader(redVS);
        redSA->addShader(redFS);

        redSA->setName("redSA");
        redSA->add("textureBase2D", osg::Uniform::SAMPLER_2D);
        redSA->set("textureBase2D", 0);

                    //Red Unit

        redUnit->setName("redUnit");
        redUnit->getOrCreateStateSet()->setAttributeAndModes(redSA);
        redUnit->setInputBypass(-1);
        redUnit->setInputTextureIndexForViewportReference(0);
        redUnit->setInputToUniform(greenUnit,"textureBase2D",true);




and the glsl green, red and blue are of this shape:


Code:

uniform sampler2D textureBase2D;

void main()
{
gl_FragColor=texture2D(textureBase2D,gl_TexCoord[0].st)+vec4(0.5,0.0,0.0,1.0);
}




To test if it works.[/code]

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





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

Reply via email to