Jump to content
• Advertisement

# tangent 4D vector in FVF

This topic is 4485 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

## 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

##### Share on other sites
Advertisement

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

##### 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

##### Share on other sites
struct Vertex
{
Vector3 p; // Vertex Position
Vector3 n; // Vertex Normal
float u, v; // Texture Coord
Vector4 t; // Tangent
};
const DWORD FVF = D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX2 | D3DFVF_TEXCOORDSIZE4(1);

Your shader will see it as TEXCOORD1.

#### Share this post

##### Share on other sites

• Advertisement
• Advertisement

• ### Popular Contributors

1. 1
2. 2
Rutin
20
3. 3
khawk
16
4. 4
A4L
14
5. 5
• Advertisement

• 11
• 16
• 26
• 10
• 11
• ### Forum Statistics

• Total Topics
633756
• Total Posts
3013707
×

## Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!