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

## 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 on other sites
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++

struct CUSTOM_VERTEX{    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 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.

D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX2 | D3DFVF_TEXCOORDSIZE2(0) | D3DFVF_TEXCOORDSIZE3(1)

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 on other sites
Im using HLSL, just wanted to see if I dumped my vertex data in the right order

1. 1
Rutin
41
2. 2
3. 3
4. 4
5. 5

• 16
• 18
• 12
• 14
• 9
• ### Forum Statistics

• Total Topics
633360
• Total Posts
3011524
• ### Who's Online (See full list)

There are no registered users currently online

×