Archived

This topic is now archived and is closed to further replies.

Tessellator

Where to put the tangent space matrices in vertex formats?

Recommended Posts

Hello, I''ve been doing simple dot3 per-pixel lighting for a while now, but my normal maps have always been in object space, so to render the map I only have to transform the light vector into the model''s local space. Of course, this makes it a bitch to animate the geometry, so instead I''ve read up on how to create a tangent (or texture) space matrix at each vertex of the model. I understand that I need to multiply the light vector by the matrix at each vertex, and then store the result in either the diffuse or specular component of the vertex (to interpolate the vector accross the triangle). However, I am not sure where to place the 3x3 matrix for each vertex. I guess I could keep a seperate array of matrices corrisponding to each vertex, and then loop through the mesh each frame to update the light vector, but this seems a bit nasty - it also means all my object VBs will have to become dynamic rather than static.. I guess I could do all this in a vertex shader to simplify things greatly, but anyhow, does anyone have some advice they''d like to give on the matter? cheers, T

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
You can store the tangent and the normal vector for every vertex as shorts. The vertex shader can do the cross product and multiply the light vector with the matrix. There is a good tutorial at http://developer.nvidia.com/view.asp?IO=skinning.

Share this post


Link to post
Share on other sites