Dear OSG users,

I am trying to develop bump mapping using opengl es 2.0 and openscenegraph.
I can't use osgFX because of opengl es 2.0.

I have to apply a bump map to an obj that has the map embedded in the MTL.

The mtl is like this:

newmtl Nuovo
Kd 0.800000 0.800000 0.800000
illum 2
Ns 50.781250
map_bump PINKGRA2_NRM.JPG
map_Kd PINKGRA2.JPG

I read the obj using the options string:

osg::ref_ptr<osgDB::ReaderWriter::Options> options = new 
osgDB::ReaderWriter::Options;
        options->setOptionString("DIFFUSE=0 BUMP=1");

To generate the tagents I use tangentspacegenerator.

osg::ref_ptr< osgUtil::TangentSpaceGenerator > tsg = new 
osgUtil::TangentSpaceGenerator;
                
tsg->generate( geo , 1);


However this is not working!!! The application crashes with a bad access!

Instead, if I use 
tsg->generate( geo, 0)
then it is working! However in this case I think it is using the diffuse map to 
generate the tangents, which I think is bad! 
The tangent space generator is created and applied inside a nodevisitor. 
I am almost sure everything is bound correctly.
.... 
    #define NORMAL_ATTR_UNIT 2
    #define TANGENT_ATTR_UNIT 9
    #define NORMAL_TEX_UNIT 1
    #define TEX_UNIT 0

    _programBumpMapping->addBindAttribLocation( "a_tangent", TANGENT_ATTR_UNIT 
);
    _programBumpMapping->addBindAttribLocation( "a_normal", NORMAL_ATTR_UNIT );
        ssRoot->setAttributeAndModes( _programBumpMapping, 
osg::StateAttribute::ON );

        ssRoot->addUniform(new osg::Uniform(osg::Uniform::SAMPLER_2D, 
"u_TextureMap", TEX_UNIT));
        ssRoot->addUniform(new osg::Uniform(osg::Uniform::SAMPLER_2D, 
"u_NormalMap", NORMAL_TEX_UNIT));
....

Can you please help me to understand why with 0 works and with 1 I have a bad 
access? 


Kind Regards,
John

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=50387#50387





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

Reply via email to