<div dir="ltr"><div><div><br>> I implemented the OSG BumpMap with no need to use shaders, as follow:<br>> osgFX::BumpMapping* bump_mapping = new osgFX::BumpMapping();<br><br></div>Hmm, by default this osgFX effect module will use shaders according to its documentation:<br><br>"This effect defines a preferred technique which uses ARB vertex & 
fragment programs, and a fallback technique which doesn't use fragment
 programs."<br><br></div><div>ARB fragment and vertex programs are some of the oldest types of programmable shaders.<br></div><div><br></div>Christian<br><br></div><div class="gmail_extra"><br><div class="gmail_quote">2016-04-04 18:12 GMT+02:00 Tiago Trocoli <span dir="ltr"><<a href="mailto:trocolit2@gmail.com" target="_blank">trocolit2@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Tobias<br>
<br>
I implemented the OSG BumpMap with no need to use shaders, as follow:<br>
<br>
function source<br>
<br>
<br>
Code:<br>
<br>
void bumpMapOSG(osg::Geode *geode, osg::Group *group, osg::Image *normal_image, osg::Image *difuse_image, double scale_x,<br>
        double scale_y) {<br>
<br>
    if (!normal_image || !difuse_image) {<br>
        std::cout << "IMAGE FAIL" << std::endl;<br>
        exit(0);<br>
    }<br>
<br>
    osg::StateSet* bumpState = new osg::StateSet();<br>
<br>
    // Set textures<br>
    osg::ref_ptr<osg::Texture2D> normal_texture(new osg::Texture2D());<br>
    osg::ref_ptr<osg::Texture2D> difuse_texture(new osg::Texture2D());<br>
<br>
    normal_texture->setImage(normal_image);<br>
    normal_texture->setDataVariance(osg::Object::DYNAMIC);<br>
    normal_texture->setFilter(osg::Texture::MIN_FILTER, osg::Texture::LINEAR_MIPMAP_LINEAR);<br>
    normal_texture->setFilter(osg::Texture::MAG_FILTER, osg::Texture::LINEAR);<br>
    normal_texture->setWrap(osg::Texture::WRAP_S, osg::Texture::REPEAT);<br>
    normal_texture->setWrap(osg::Texture::WRAP_T, osg::Texture::REPEAT);<br>
    normal_texture->setResizeNonPowerOfTwoHint(false);<br>
    normal_texture->setMaxAnisotropy(8.0f);<br>
<br>
    difuse_texture->setImage(difuse_image);<br>
    difuse_texture->setDataVariance(osg::Object::DYNAMIC);<br>
    difuse_texture->setFilter(osg::Texture::MIN_FILTER, osg::Texture::LINEAR_MIPMAP_LINEAR);<br>
    difuse_texture->setFilter(osg::Texture::MAG_FILTER, osg::Texture::LINEAR);<br>
    difuse_texture->setWrap(osg::Texture::WRAP_S, osg::Texture::REPEAT);<br>
    difuse_texture->setWrap(osg::Texture::WRAP_T, osg::Texture::REPEAT);<br>
    difuse_texture->setResizeNonPowerOfTwoHint(false);<br>
    difuse_texture->setMaxAnisotropy(8.0f);<br>
<br>
    const int TEXTURE_UNIT_NORMAL = 1;<br>
    const int TEXTURE_UNIT_DIFUSE = 2;<br>
<br>
    bumpState->setTextureAttributeAndModes(TEXTURE_UNIT_NORMAL, normal_texture, osg::StateAttribute::ON);<br>
    bumpState->setTextureAttributeAndModes(TEXTURE_UNIT_DIFUSE, difuse_texture, osg::StateAttribute::ON);<br>
<br>
    osg::ref_ptr<osg::Geometry> geometry = geode->asGeode()->getDrawable(0)->asGeometry();<br>
    osg::Vec2Array* tex_coord = dynamic_cast<osg::Vec2Array*>(geometry->getTexCoordArray(0));<br>
<br>
    for (unsigned int i = 0; i < tex_coord->getNumElements(); ++i)<br>
        (*tex_coord)[i].set((*tex_coord)[i].x() * scale_x, (*tex_coord)[i].y() * scale_y);<br>
<br>
    geometry->setStateSet(bumpState);<br>
    if (tex_coord) {<br>
        geometry->setTexCoordArray(TEXTURE_UNIT_NORMAL, tex_coord);<br>
        geometry->setTexCoordArray(TEXTURE_UNIT_DIFUSE, tex_coord);<br>
    } else {<br>
        std::cout << "MISS TEXTURE COORDINATE " << std::endl;<br>
        exit(0);<br>
    }<br>
<br>
    osgFX::BumpMapping* bump_mapping = new osgFX::BumpMapping();<br>
    bump_mapping->setEnabled(true);<br>
    bump_mapping->setLightNumber(0);<br>
    bump_mapping->setNormalMapTextureUnit(TEXTURE_UNIT_NORMAL);<br>
    bump_mapping->setDiffuseTextureUnit(TEXTURE_UNIT_DIFUSE);<br>
    bump_mapping->addChild(geode);<br>
    bump_mapping->prepareChildren();<br>
    group->addChild(bump_mapping);<br>
<br>
}<br>
[\code]<br>
<br>
<br>
<br>
Thank you!<br>
<br>
Cheers,<br>
Tiago<br>
<br>
<br>
<br>
------------------<br>
Read this topic online here:<br>
<a href="http://forum.openscenegraph.org/viewtopic.php?p=66724#66724" rel="noreferrer" target="_blank">http://forum.openscenegraph.org/viewtopic.php?p=66724#66724</a><br>
<br>
<br>
<br>
<br>
<br>
_______________________________________________<br>
osg-users mailing list<br>
<a href="mailto:osg-users@lists.openscenegraph.org">osg-users@lists.openscenegraph.org</a><br>
<a href="http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org" rel="noreferrer" target="_blank">http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org</a><br>
</blockquote></div><br></div>