Hi,
I am trying to extract the texture from an .ive that is read using osgDB into a
node and will be passed as a sample2DRect uniform for the shader. So to make it
sort, how do I do that?
The code so far:
Code:
osgDB::Registry::instance()->getDataFilePathList().push_back("resources/SmileFace");
const std::string smileyFilename = "SmilingFaceDiff0.IVE";
//osgDB::Registry::instance()->getDataFilePathList().push_back("resources/SmileFace2");
//const std::string smileyFilename = "SmilingFace.IVE";
osg::ref_ptr<osg::Node> smiley = osgDB::readNodeFile(smileyFilename);
if(smiley.valid())
{
//Set StateSet
osg::StateSet* ss = new osg::StateSet;
ss->setTextureMode(0, GL_LIGHTING, osg::StateAttribute::OFF);
ss->addUniform( new osg::Uniform( "baseTexture", 0 ) ); //Umm,
where did baseTexture come from? need to extract from the ive
smiley->setStateSet(ss);
//Set Programs
osg::ref_ptr<osg::Program> program = new osg::Program;
char vertexSource[]=
"void main(void)\n"
"{\n"
" gl_Position = ftransform();\n"
" gl_TexCoord[0] = gl_MultiTexCoord0;\n"
"}\n";
char fragmentSource[]=
"uniform sampler2DRect baseTexture;\n"
"\n"
"void main(void)\n"
"{\n"
" gl_FragColor = texture2DRect( baseTexture,
gl_TexCoord[0] );\n"
" gl_FragColor.a = 0.05;\n"
"}\n";
program->setName( "alpha_test" );
program->addShader(new osg::Shader(osg::Shader::VERTEX,
vertexSource));
program->addShader(new osg::Shader(osg::Shader::FRAGMENT,
fragmentSource));
ss->setAttributeAndModes( program, osg::StateAttribute::ON );
}
Thank you!
Cheers,
Bawenang
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=36403#36403
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org