Jump to content
  • Advertisement
Sign in to follow this  
Simplicity

Vertex Packing

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

For D3D FVF, the packing of vertex elements (e.g position, normal, texcoor) must be in specific order. If we use vertex declaration, do they have to be in specific order as well?

Share this post


Link to post
Share on other sites
Advertisement
yes, IMHO it´s very important.
If you´ve have a disordered vertex declaration
(not identical with your vertex struct) you´ve got
problems.
(i´ve got, using MDX)

Greetings *Los Brutalos*

Share this post


Link to post
Share on other sites
In d3d9, no. You can build your decl in any order you want, and declare the parameter semantics in a shader in any order you want; the runtime will route elements to where they need to go. This is (marginally) useful if you want to use the same VB to render to two different shaders, each of which might use different components of the vertex data.

Share this post


Link to post
Share on other sites
@rendertarget
Argl ... did i something wrong ??
I do not use semantics yet, cause noone was able to explain the advantages
of that to me ... ;)
Thanks. maybe the wrong answer from me will help me too.

Share this post


Link to post
Share on other sites
You should definitely use input and output semantics in your shaders. It's self-documenting if nothing else, but also ensures things end up where they should.

Share this post


Link to post
Share on other sites
@rendertarget:
Hmmm. this will explain the problems i´ve got it the first time
writing shaders.
But one question further more:
Are the names for the semantics of your free choice or are they boundes
to some DX stuff (fixed names) ?
Most of shader samples i seen use semantics like WORLD or
VIEW or something like tgis (wich makes sense at all) but am
i able to name them e.g. SANTA or CLAUSE ;) ?
(if i want to)


Share this post


Link to post
Share on other sites
Quote:
Original post by LosBrutalos
@rendertarget:
Hmmm. this will explain the problems i´ve got it the first time
writing shaders.
But one question further more:
Are the names for the semantics of your free choice or are they boundes
to some DX stuff (fixed names) ?
Most of shader samples i seen use semantics like WORLD or
VIEW or something like tgis (wich makes sense at all) but am
i able to name them e.g. SANTA or CLAUSE ;) ?
(if i want to)


Input and output semantics -- those semantics you apply to input and output variables -- need to be the standard ones: POSITION, NORMAL, BLENDWEIGHT, COLOR, etc. This is how D3D knows where to map things. (Note that this is all HLSL.)

Share this post


Link to post
Share on other sites
What I meant is the ordering of vertex elements, are the fixed or flexible just as long as the order match with the order of the vertex declaration. Can we just use vertex declaration for both fixed function pipeline and shaders and get rid of FVF altogether?

Share this post


Link to post
Share on other sites
Yes you can. If you set a vertex declaration but no vertex shader Direct3d do a fallback to the fixed function pipeline and use the elements you have specified in your vertex declaration.

You have to make sure that your vertex declaration contains the right types and usages for your elements. This list should help you:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/Mapping_between_a_DirectX_9_Declaration_and_FVF_Codes.asp

Share this post


Link to post
Share on other sites
So element order in the vertex structure doesn't matter as long as it conforms to the ordering of the vertex declaration? Because for FVF, say we have 3 floats for position and a DWORD for diffuse color, no matter what the position must be declared in the struct before the diffuse color.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!