Can D3DFVF_DIFFUSE be used with D3DFVF_NORMAL?

Started by
5 comments, last by johnnyBravo 17 years, 11 months ago
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!
Advertisement
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.
enum Bool { True, False, FileNotFound };
Quote:Original post by hplus0603
declare your vertex array layouts using vertex declarations instead of FVFs.


What should I search to learn about this?

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



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

This topic is closed to new replies.

Advertisement