Hello Juan, That is right, I forgot the line which attach the stateset to the node. The "stack" get the stateset.
stack->setStateSet(stateset) Yes the baseTex is bound as input texture and it is also the render target of the FBO. I thought I can use the blendequation for the iterative adding of a texture. Did I misunderstood that? Best regards, Martin -------- Original-Nachricht -------- > Datum: Tue, 22 Feb 2011 18:25:04 +0100 > Von: Juan Hernando <jherna...@fi.upm.es> > An: OpenSceneGraph Users <osg-users@lists.openscenegraph.org> > Betreff: Re: [osg-users] Can I increment the gl_FragData? > I don't fully understand the purpose of the code. What operation are you > trying to carry out with the textures and how are you using/displaying > the result? > Nevertheless, I see one serious mistake in your code, baseTex is bound > as an input texture in texQuad1 and it's also the render target of the > FBO. Probably that's the reason for which you're seeing strange results > (no increment, or "infinite mirror artifacts"). > Also I don't see to which node are you attaching the stateSet, did you > forget to paste the code in your mail? > > Juan > > > My blending version doesn't work. > > Parts of the code: > > > > // 1. create RTT-Texture (Rendertarget) > > ref_ptr<Texture2D> baseTex = createRenderTexture(width,height); > > > > // 2. Blend Texture > > ref_ptr<Texture2D> blendTex = new Texture2D; > > blendTex->setImage(osgDB::readImageFile(argv[2])); > > > > // 3. Quads > > ref_ptr< TexturedQuad> texQuad1 = new TexturedQuad(baseTex.get()); > > ref_ptr< TexturedQuad> texQuad2 = new TexturedQuad(blendTex.get()); > > > > // 4. Stack (Quad stack) > > ref_ptr<Group> stack = new Group; > > > > ref_ptr<MatrixTransform> mt1 = new MatrixTransform; > > mt1->setMatrix(Matrix::translate(0,0,-1)); > > mt1->addChild(texQuad1); > > stack->addChild(mt1); > > > > ref_ptr<MatrixTransform> mt2 = new MatrixTransform; > > mt2->setMatrix(Matrix::translate(0,0,0)); > > mt2->addChild(texQuad2); > > stack->addChild(mt2); > > > > // 5. BlendEquation > > BlendEquation* blendEquation = new > BlendEquation(BlendEquation::FUNC_ADD); > > blendEquation->setDataVariance(Object::DYNAMIC); > > > > // 6. BlendFunc > > ref_ptr<BlendFunc> blendFunc = new BlendFunc(); > > blendFunc->setFunction(BlendFunc::ONE,BlendFunc::DST_COLOR ); > > > > // 7. StateSet > > StateSet* stateset = new StateSet; > > > > stateset->setDataVariance(Object::DYNAMIC); > > > stateset->setAttributeAndModes(blendEquation,StateAttribute::OVERRIDE|StateAttribute::ON); > > stateset->setAttributeAndModes(blendFunc, StateAttribute::ON); > > stateset->setRenderingHint(StateSet::TRANSPARENT_BIN); > > stateset->setMode(GL_BLEND, StateAttribute::ON); > > > > // 8. RTT Camera > > osg::Camera* rtt_cam = new osg::Camera; > > rtt_cam->setClearColor(osg::Vec4(0,0,0,0)); > > //rtt_cam->setClearMask( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); > > rtt_cam->setViewport(0,0,width,height); > > rtt_cam->setRenderOrder(osg::Camera::PRE_RENDER, 0); > > rtt_cam->setRenderTargetImplementation( osg::Camera::FRAME_BUFFER ); > > rtt_cam->attach(osg::Camera::COLOR_BUFFER0, baseTex, 0, 0); > > rtt_cam->setReferenceFrame(osg::Transform::ABSOLUTE_RF); > > rtt_cam->setProjectionMatrixAsOrtho2D(0.0,1.0,0.0,1.0); > > rtt_cam->setViewMatrix(osg::Matrix::identity()); > > rtt_cam->addChild(stack); > > > _______________________________________________ > osg-users mailing list > osg-users@lists.openscenegraph.org > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org -- NEU: FreePhone - kostenlos mobil telefonieren und surfen! Jetzt informieren: http://www.gmx.net/de/go/freephone _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org