Sign in to follow this  
johnnyBravo

Can D3DFVF_DIFFUSE be used with D3DFVF_NORMAL?

Recommended Posts

Hi, i was wondering if D3DFVF_DIFFUSE can be used with D3DFVF_NORMAL when rendering a vertex with lighting? Because I remember reading somewhere in the dxsdk docs that you can't, but I can't seem to find that reference now. thx!

Share this post


Link to post
Share on other sites
I believe you can; at least if you enable auto-material.

However, I would, in general, recommend that you declare your vertex array layouts using vertex declarations instead of FVFs. There are so many things that just get in the way when using FVFs.

Share this post


Link to post
Share on other sites
Quote:
Original post by hplus0603
declare your vertex array layouts using vertex declarations instead of FVFs.


What should I search to learn about this?

Share this post


Link to post
Share on other sites
You can use D3DFVF_DIFFUSE and D3DFVF_SPECULAR to replace one of the materials color component for each vertex. This is controlled by the D3DRS_COLORVERTEX render state (default is on). To select the source for every material color you have to use the D3DRS_DIFFUSEMATERIALSOURCE D3DRS_SPECULARMATERIALSOURCE D3DRS_AMBIENTMATERIALSOURCE and D3DRS_EMISSIVEMATERIALSOURCE renderstate. For each you can select the diffuse vertex color, the specular or the entry in your material. The default is that ambient and emissive colors are provided from the material, the diffuse color comes from the diffuse vertex entry and the specular one from the vertex two. If your vertex doesn’t provide the necessary colors Direct3D will fall back to the material colors.

hplus0603, I agree that vertex declaration are better than FVFs but in the case of the fixed function pipeline the only buy you the ability to order your data anyway you want and use multiple streams. The fixed pipeline still limits you in the useable usage elements.

Share this post


Link to post
Share on other sites
Quote:
Original post by johnnyBravo
Quote:
Original post by hplus0603
declare your vertex array layouts using vertex declarations instead of FVFs.


What should I search to learn about this?


As you have worked with FVFs until now this should a good starting point: 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
No, you can give one vertex more than one flag. Just or them together: D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE
but you have to be careful you can't combine every flag with every other (for example you can't use D3DFVF_XYZ with D3DFVF_XYZRHW)


You don't have to use the index buffer, but it's an easy way (more or less) to avoid duplicating vertices and thus you can safe space.
You store every vertec only once in a vertex buffer and then use a index buffer to store which of those vertices make up your primitives.

Share this post


Link to post
Share on other sites
Quote:
Original post by ext
No, you can give one vertex more than one flag. Just or them together: D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE
but you have to be careful you can't combine every flag with every other (for example you can't use D3DFVF_XYZ with D3DFVF_XYZRHW)


You don't have to use the index buffer, but it's an easy way (more or less) to avoid duplicating vertices and thus you can safe space.
You store every vertec only once in a vertex buffer and then use a index buffer to store which of those vertices make up your primitives.


Sorry I forgot to mention in my last post that I was talking about vertex streams.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this