Hi. I've found out the problem: TangentSpaceGenerator always uses the same arrays T_, B_, N_ for all geometries. In my code I get only Tangents this way:
osg::Vec4Array *a = mTSG->getTangentArray(); geom->setVertexAttribArray(mTangentID, a); Since setVertexAttribArray accepts a pointer, ALL geometries share the same T_, B_, N_ arrays! That's why, in my case, adding another geometry broke previous one. I've fixed it by simple copying: osg::Vec4Array *a = mTSG->getTangentArray(); osg::Vec4Array *copy = static_cast<osg::Vec4Array*>(a->clone(osg::CopyOp::DEEP_COPY_ARRAYS)); geom->setVertexAttribArray(mTangentID, copy); And that helped! If this approach is acceptable, I can modify TSG and provide it. Thanks. 2014-03-15 15:17 GMT+07:00 michael kapelko <[email protected]>: > Hi. > I experience some weird results of TSG too. > Here's the scene with only one object (valid normal mapping): > https://dl.dropboxusercontent.com/u/12634473/img/20140315_tsg_valid.png > Here's the scene with 2 objects (invalid normal mapping): > https://dl.dropboxusercontent.com/u/12634473/img/20140315_tsg_invalid.png > Just adding an object to the scene breaks everything. So I'm more than > sure that TSG is buggy. > > I will post more results when I advance in my investigation. > The complete source code of what I'm doing (depends on my forked > osgEffectCompositor): http://goo.gl/O5sAmm > > Thanks. > > > 2013-10-01 16:06 GMT+07:00 Nicoulaie Vernouillet <[email protected]> > : > >> Hi, robert >> >> here is the test case. these are just two faces that share the same >> normal, but have non-collinear uv coordinates. "with_add.osg" file >> accumulates the calculated tangent and binormal, while "withou_add.osg" >> crushes the previous calculations. >> >> I made a little diagram to explain what happens at the shared vertex. >> we realize that if the direction of uv is not collinear it overwrites the >> information from the previous face. And during rasterization, the linear >> interpolation is performed in the middle of the first face and not between >> the two side of the edge. >> >> I hope to be clear enough, feel free to ask me any other information if >> this is not enough. >> >> Thank you! >> >> Cheers, >> Nicoulaie[/img] >> >> ------------------ >> Read this topic online here: >> http://forum.openscenegraph.org/viewtopic.php?p=56553#56553 >> >> >> >> >> _______________________________________________ >> osg-submissions mailing list >> [email protected] >> >> http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org >> >> >
_______________________________________________ osg-submissions mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
