where can i find the D3DFVF format

Started by
20 comments, last by tcige 11 years ago

where can i find the detail of all kinds of D3DFVF format

directx 8 docs.

i've got a copy of the chart you need, but gamedev.net's editor can't paste it into this post, i'll try uploading it to my gallery or journal.

thanks for the info

where can i download the directx 8 sdk

Advertisement

i posted the chart from the directx8 docs in my gallery:

http://www.gamedev.net/gallery/image/3560-fvfcodes/

lemme check my code, and i'll see if i can explain what's up in my next post. i use fvf too.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

>> where can i download the directx 8 sdk

its still out there on a few sites, but that image is all you need out of it. the june 2010 sdk docs cover everything else RE: fixed function and FVF codes.

if you're just starting out, you might just want to learn the newer way. its forward compatible, FVF is not.

i'll check my code and see if i can explain what's up with fvf's.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

You have to define this structure yourself, the DX SDK will not define this for you as it wouldn't know what needs you have for your vertex structure. Mesh data is very specific to the project it is being used in and some projects use position, normal, tangent and a couple of texture coordinate sets and others leave out the tangent data and calculate that in the shader.

What goes into the vertex buffer in the end is up to you. I could also have used this as the CustomVertex structure


struct CustomVertexColor
{
    float x, y, z; //position
    float nx, ny, nz; //normal
    DWORD diffuse; //Diffuse color
    float u, v; //texture coordinates
};
 
DWORD CustomVertexFVF = D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE | D3DFVF_TEX0 |
D3DFVF_TEXCOORDSIZE2(0);

The thing is I remember that you need to be careful with the order in the struct and FVF, I haven't used the Fixed Function pipeline in years so this information is a bit hazy.

Using VERTEXELEMENT9 and the D3D11 equivalents of this are far easier to manage as you are literally telling the vertex buffer how it has been laid out and you could potentially put the normal in front of the position if you wanted to.

thanks a lot

i do not mean that, for example, the texture

how can i known what addictional info needs in the structure except xyz

That's completely up to you to be honest, but there are a few things that are needed to do certain things, like:

  • Wanna do lighting you need to provide a normal
  • Wanna do texture mapping you need to provide at least one set of texture coordinates.

This link should give you more information on when to use what in a vertex buffer, it also relates this information to certain features you can turn on in the Fixed Function pipeline in D3D9.

ok I found a link to the order of the structure related to the FVF again: http://p.blog.csdn.net/images/p_blog_csdn_net/yanonsoftware/fvf_order.gif

Again I advice you to start looking at the programmable pipeline instead as the Fixed Function pipeline isn't used anymore in anything but legacy code.

Worked on titles: CMR:DiRT2, DiRT 3, DiRT: Showdown, GRID 2, theHunter, theHunter: Primal, Mad Max, Watch Dogs: Legion

i posted the chart from the directx8 docs in my gallery:

http://www.gamedev.net/gallery/image/3560-fvfcodes/

lemme check my code, and i'll see if i can explain what's up in my next post. i use fvf too.

the chart is great

maybe the directx 8 header file contains the detail info of every structure

thanks for the info and advise

You have to define this structure yourself, the DX SDK will not define this for you as it wouldn't know what needs you have for your vertex structure. Mesh data is very specific to the project it is being used in and some projects use position, normal, tangent and a couple of texture coordinate sets and others leave out the tangent data and calculate that in the shader.

What goes into the vertex buffer in the end is up to you. I could also have used this as the CustomVertex structure


struct CustomVertexColor
{
    float x, y, z; //position
    float nx, ny, nz; //normal
    DWORD diffuse; //Diffuse color
    float u, v; //texture coordinates
};
 
DWORD CustomVertexFVF = D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE | D3DFVF_TEX0 |
D3DFVF_TEXCOORDSIZE2(0);

The thing is I remember that you need to be careful with the order in the struct and FVF, I haven't used the Fixed Function pipeline in years so this information is a bit hazy.

Using VERTEXELEMENT9 and the D3D11 equivalents of this are far easier to manage as you are literally telling the vertex buffer how it has been laid out and you could potentially put the normal in front of the position if you wanted to.

thanks a lot

i do not mean that, for example, the texture

how can i known what addictional info needs in the structure except xyz

That's completely up to you to be honest, but there are a few things that are needed to do certain things, like:

  • Wanna do lighting you need to provide a normal
  • Wanna do texture mapping you need to provide at least one set of texture coordinates.

This link should give you more information on when to use what in a vertex buffer, it also relates this information to certain features you can turn on in the Fixed Function pipeline in D3D9.

ok I found a link to the order of the structure related to the FVF again: http://p.blog.csdn.net/images/p_blog_csdn_net/yanonsoftware/fvf_order.gif

Again I advice you to start looking at the programmable pipeline instead as the Fixed Function pipeline isn't used anymore in anything but legacy code.

thanks for the info and advise

ok, i'm only using fvf's for a test of drawing dynamically height mapped ground quads, and for drawing meshes.

for the ground quad test, i'm using this vertex format:

const DWORD ZFVF=(D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1 | D3DFVF_TEXCOORDSIZE2(0) );
struct Zvertexrec
{
float x,y,z;
float nx,ny,nz;
float tu,tv;
DWORD diffuse,specular;
};
so these have position for drawing, normals for lighting, texture coords for texturing, and diffuse and specular lighting components.
but that was just a test.
in my actual code, i just call mesh.getfvf, and then call set_fvf. then i set my vertex and index buffers and call drawprimitive.
the meshes are made in truespace, and use its built-in .x export capability to save them as .x files. the .x files are loaded at program start, and are a convenient way for me to store vertex and index buffers for drawing.
as i recall, their vertex format is x,y,z,normal,u,v.
as i recall, diffuse and specular are only used when you're not texture mapping.
so here's the process:
1. figure out what you need. xyz, normal, u,v etc... xyz normal and uv might be enough for basic texturermapping and lighting.
2. declare your struct.
3. declare your fvf code dword (like my ZFVF above)
4. call set_fvf(myfvf_dword)

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

> maybe the directx 8 header file contains the detail info of every structure

dude, you don't get it, there ARE no structures.

you make them yourself, then use fvf codes to tell directx what you put in them.

all the possible combos would be a nightmare to deal with, so microsoft left it up to the user to declare the struct in a certain order, then uses fvf codes to tell directx how to read it.

so there isn't a "xyz,normal,uv" struct in directx at all. or any of the other possible struct declarations you could get from all possible fvf code combos.

you make the struct. the order in the chart and the fvf codes allow directx to read it correctly.

the fvf codes define what fields you can include. the docs about the fvf flags tell what they do, but they don't explain about the order of appearance in the struct very well or at all.

i've never checked to see if the flags are listed in the docs in the order that the fields must appear or not.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

That depends on your render states that are setup on the device and on the material settings. If D3DRS_VERTEXCOLOR is set and lighting is also enabled it will use the per vertex color values in this calculation. By default it's set to true.

Worked on titles: CMR:DiRT2, DiRT 3, DiRT: Showdown, GRID 2, theHunter, theHunter: Primal, Mad Max, Watch Dogs: Legion

That depends on your render states that are setup on the device and on the material settings.

yes, i suspected that material was involved. when you export just a mesh by itself from truespace with uv and normals only, it does not include lighting in the vertices, so directx just uses the material (i'm pretty sure). i use global materials to control specular and diffuse when drawing scenes.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

This topic is closed to new replies.

Advertisement