Sign in to follow this  
shaquill

tangent 4D vector in FVF

Recommended Posts

Hi, I visited "http://www.terathon.com/code/tangent.php" and I understand how to calulate tagent vector. anyway it's 4d vector. The last w factor is for Binormal's sign I think. And I don't know how to put 4d vector into FVF correctly. there is no define for 4d tangent vector. should I use D3DFVF_XYZW for 4d tangent vector? so it could be... struct Vertex { Vector3 p; // Vertex Position Vector3 n; // Vertex Normal Vector4 t; // Tangent float u, v; // Texture Coord }; const DWORD FVF = D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_XYZW | D3DFVF_TEX1; Am I right? I'm not sure...^^;; thanks.

Share this post


Link to post
Share on other sites

D3DFVF_? don't contain flags for setting tangents. Practically you'd need to use a 3d texture coordinate or pack the tangent and bitangent in the diffuse/specular dwords.

So the vertex format you describe isn't really valid since D3DFVF_XYZW refers to the position vector.

Tangent/Bitangent are really only 3d.

You could use a vertex declaration which is far more handy in this case.

Share this post


Link to post
Share on other sites
What he said. :)

I'd like to add that you must remember that FVF is just a collection of flags. There order you write things in doesn't affect the result. So

const DWORD FVF = D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_XYZW | D3DFVF_TEX1;

is the same as, for example,

const DWORD FVF = D3DFVF_XYZ | D3DFVF_XYZW | D3DFVF_NORMAL | D3DFVF_TEX1;

Which is why there's no way what you wrote would translate to a meaningful structure. (And, as Demus79 said, is meaningless, since both D3DFVF_XYS and D3DFVF_XYZW refer to position, and can't be specified together.)

Like Demus said, using a vertex declaration would be better. It's a lot clearer in the sense that it defines the structure specifically, instead of using a fixed order of components and a set of flags.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this