Hi all,
I am trying to overlay a shape file on a terrain using overlay node. But the two textures are not blending, instead the overlay texture has replaced the terrain texture. I am attaching the final rendered image for you to ponder upon. I am using the code of osgsimulation example which goes like this for my case.

// Get coordinate system node
osg::CoordinateSystemNode* csn = dynamic_cast<osg::CoordinateSystemNode*>(terrain.get());

// Set overlay technique
osgSim::OverlayNode::OverlayTechnique technique = osgSim::OverlayNode::OBJECT_DEPENDENT_WITH_ORTHOGRAPHIC_OVERLAY;

// Create overlay node
osgSim::OverlayNode* overlayNode = new osgSim::OverlayNode(technique);

// Set blending parameters
overlayNode->getOrCreateStateSet()->setRenderingHint(osg::StateSet::TRANSPARENT_BIN); overlayNode->getOrCreateStateSet()->setMode(GL_BLEND, osg::StateAttribute::ON);

overlayNode->getOrCreateStateSet()->setTextureAttribute(1, new osg::TexEnv(osg::TexEnv::BLEND));
overlayNode->setOverlaySubgraph(shapefile.get());
overlayNode->setOverlayTextureSizeHint(1024);
overlayNode->setOverlayTextureUnit(1);

// Set clear color
overlayNode->setOverlayClearColor(osg::Vec4(0.0, 0.0, 0.0, 0.0));

// insert the OverlayNode between the coordinate system node and its children.
for(unsigned int i=0; i<csn->getNumChildren(); ++i)
{
       overlayNode->addChild( csn->getChild(i) );
}

csn->removeChildren(0, csn->getNumChildren());
csn->addChild(overlayNode);

// Set scene data
viewer.setSceneData(csn);



best regards
RJ

<<inline: combined.png>>

_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to