Hello everyone: i have a question regarding how to pass texture to shader
There were some code in the tutorial, such as: Code: bumpMapProgramObject->addShader( bumpFragmentObject ); bumpMapProgramObject->addShader( bumpVertexObject ); osg::Uniform* lightPosU = new osg::Uniform("LightPosition",osg::Vec3(0,0,1)); osg::Uniform* normalMapU = new osg::Uniform("normalMap",1); osg::Uniform* baseTextureU = new osg::Uniform("baseTexture",0); bumpMapState->addUniform(lightPosU); bumpMapState->addUniform(normalMapU); bumpMapState->addUniform(baseTextureU); lightPosU->setUpdateCallback(new updateBumpShader() ); bumpMapState->setAttributeAndModes (bumpMapProgramObject, osg::StateAttribute::ON); osg::Texture2D* tankBodyNormalMap = new osg::Texture2D; tankBodyNormalMap->setDataVariance(osg::Object::DYNAMIC); osg::Image* tankBody = osgDB::readImageFile("TankBump.png"); if (!tankBody) { std::cout << " couldn't find texture, quiting." << std::endl; return -1; } tankBodyNormalMap->setImage(tankBody); bumpMapState->setTextureAttributeAndModes (1,tankBodyNormalMap,osg::StateAttribute::ON); Here, the example creates osg::Uniform* normalMapU = new osg::Uniform("normalMap",1); '1'is the initial value of normalMap? how to link to texture unit in shader? using (Am I right?) bumpMapState->setTextureAttributeAndModes (1,tankBodyNormalMap,osg::StateAttribute::ON); here the value of first parameter should be the same as initial value in the 'new osg::Uniform("normalMap",1);' and the way to have the 'tankBodyNormalMap' in bumpmap.vert, using gl_MultiTexCoord0 or gl_MultiTexCoord1? where we can find bumpmap.vert? Thank you! Cheers, Nan ------------------ Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=38982#38982 _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org