[osg-users] Tangent, Binormal and Normal Calculation to GLSL on OSG

David Spilling david.spilling at gmail.com
Thu Sep 25 05:11:42 PDT 2008

Hi Umit,

Assuming you are loading an external model, your model will need to have
tangent and binormal attributes associated with its vertices.

Even if you can do this in your modelling package, I'm not sure if any of
the intermediate formats will read/write tangents and binormals. (Other than
.osg, of course. Does anybody out there know?)

Therefore you will most likely need to generate tangent and binormals within
your application. In the first instance you will need a model with UV
texture coordinates assigned. You should look at
osgUtil:TangentSpaceGenerator and use that to generate and attach tangent
and binormal vector arrays to your geometry. If you have more than one
geometry (in particular if you load up a model) you will need to write a
Visitor which will traverse your model scenegraph and generate all the
tangent/binormals itself. The osgFX::BumpMapping technique gives a good
example of how the TangentSpaceGenerator is actually used with a Visitor

Of course, if you are generating your geometry on-the-fly from within your
application, then you don't need all of this stuff. Just generate a
Vec3Array with the right vectors in it for binormal and tangent, and attach
them to the geometry (in otherwise unused vertex attribute numbers like 6
and 7, otherwise strange things will happen). Again, have a look at how
osgFX::BumpMapping does it.

Hope that helps,

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20080925/43372a64/attachment-0003.htm>

More information about the osg-users mailing list