Hi Selman Abi, Firsty if you have textures in your hand seperatly you can use this code to send textures in uniform variable,
// Create a texture object osg::Texture2D * normal = new osg::Texture2D; normal->setImage( osgDB::readImageFile( "XXX" ) ); normal->setWrap( osg::Texture2D::WRAP_S, osg::Texture2D::REPEAT ); normal->setWrap( osg::Texture2D::WRAP_T, osg::Texture2D::REPEAT ); normal->setResizeNonPowerOfTwoHint( false ); normal->setMaxAnisotropy( 8.0f ); // Set up the shader stateset, geode is your target model which shader operaion will be implemented osg::StateSet * stateset = geode->getOrCreateStateSet(); stateset->setTextureAttribute( BASE_TEX_UNIT, normal ); // Them send this texture unit which normal texture already set. baseMap is uniform variable which you will use in your vertex or fragment shader. stateset->addUniform( new osg::Uniform( "baseMap", BASE_TEX_UNIT ) ); Sending a texture to shader composes of this 3 steps. If you haven't texture names and locations readymade, you may use 2 ways which I know to get them. Firstly you can write texture visitors, and you can traverse the texture nodes to get the textures information. I haven't try this but it could work for you :) Second you can convert your ive models to osg by osgconv and then you can get the texture names by using only notepad. Hope this helps. Best Regards. 2009/1/15 selman duatepe <[email protected]> > Hi Ümit, > > Actually, I want to know solutions of two combinations. > > Firstly, if textures are seperated from models, how can I pass the texture > in uniform variables? I have lots of models and I don't know whole > information about textures (name, location vs.). Can I get information about > model textures from ive model? > > Thanks Ümit. > > > On Wed, Jan 14, 2009 at 4:37 AM, Ümit Uzun <[email protected]> wrote: > >> Hi Selman Abi, >> >> What do you mean you can't pass textures to shaders? Textures are >> separated from models or they are integrated combination? If they separated >> you can easily pass texture in uniform variables, or they are combined with >> model like ive Terrain models there can be problem as you said. >> >> Best Regards. >> >> 2009/1/13 Lukas Diduch <[email protected]> >> >> Play around with the notify level for debug info. >>> (from doc:) >>> >>> export OSG_NOTIFY_LEVEL= >>> >>> * ALWAYS >>> * FATAL >>> * WARN >>> * NOTICE >>> * DEBUG_INFO >>> * DEBUG_FP >>> * DEBUG >>> * INFO, will also enable validation of shader programs >>> >>> >>> On Tue, Jan 13, 2009 at 05:33:27PM +0200, selman duatepe wrote: >>> > Hi everyone, >>> > >>> > I want to render *ive* model with textures by shaders. But, I can't >>> pass the >>> > textures to fragment or vertex shader. >>> > >>> > Any ideas? >>> > >>> > Thanks. >>> >>> > _______________________________________________ >>> > osg-users mailing list >>> > [email protected] >>> > >>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org >>> _______________________________________________ >>> osg-users mailing list >>> [email protected] >>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org >>> >> >> >> >> -- >> Ümit Uzun >> >> _______________________________________________ >> osg-users mailing list >> [email protected] >> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org >> >> > > _______________________________________________ > osg-users mailing list > [email protected] > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > > -- Ümit Uzun
_______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

