Jump to content
  • Advertisement
Sign in to follow this  

[Resolved]Vertex Format, please tell me if this is correct.

This topic is 4789 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

X As Single Y As Single Z As Single Normal As Vector3 Tu As Single Tv As Single Tangent As Vector3 I am fairly sure I have the position, normal and texture coordinates in the right order. I am using Vector3 because DirectX reads it off as a byte stream, not as a structure, so I can use this convenient naming convetion. Is the tangent in the correct place? [Edited by - CadeF on October 8, 2005 8:01:42 AM]

Share this post

Link to post
Share on other sites
Good morning CadeF,
How are you doing?

The Problem
Vertex Format questions.

The Solution
Normally you would want to provide precision for the positions and normals.
for example.
float x, y, z,
nx, ny, nz;
I just tend of provide my uv coordinates a float aswell for uniform code.
float u, v;
The order in which you specify your vertex format would depend on the format you chose. Here is an example in c++

float x, y, z;
float u1, v1;
float u2, v2;
const static DWORD fvf = D3DFVF_XYZ | D3DFVF_TEX2;

I hope this helps a bit.
Take care bud.

Share this post

Link to post
Share on other sites
The fixed pipeline has no idea what a tangent is. You can pretend it's a texture coordinate and continue to use an FVF, or you can move to vertex declarations. In a vertex declaration you can put any data, in any order, at any offset. Want normals before position? No problem. If you're using shaders (which you'll need if your doing anything with tangent vectors), you might as well use a vertex declaration too.

If you want to use an FVF, this page defines the order things must come in, so your order is fine, and you'd do this.


Note that setting the size to 2 can be omitted, as it's the default. Also note that we're encoding the tangent as a second texture coordinate, of size 3.

An advantage to using vertex declarations is that they're more up to date. You can indicate the tangent is a 2nd UV, or you can specify it's a tangent. Binding the correct data in a shader is simpler when you're able to specify that your tangent data is tangent data, not extra UVs. Other than that, both methods are pretty much identical.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!