• ### Popular Now

• 13
• 12
• 9
• 10
• 13

#### Archived

This topic is now archived and is closed to further replies.

# DIFFUSE & NORMAL coexisting

This topic is 5392 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I have an idea to select rendering modes: Lighting and Vertex colored, so I came up with this model: I have an FVF which has both DIFFUSE and NORMAL, pretty much like the following: const DWORD FVFTEST = D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_NORMAL | D3DFVF_TEX2; and a vertex structure:
struct TEST1
{
float x,y,z;
float nx,ny,nz;
DWORD diffuse;
float tu, tv;
};

Then, I would change between vertex color and D3D lighting, using the Renderstate D3DRS_*MATERIALSOURCE. Now, my question is, would this be efficient? Would it even work? I can do it with 2 separate types, a lit vertex and a normal vertex, but that would require 2x more calculation time (its for my terrain engine btw.) That''s it. I hope there is an answer.

##### Share on other sites
Yes, it works fine. We use it here all the time. I''ve heard many times that it''s an odd combination since you''re either calculating lighting, or using prelit vertices. While that''s true, there are other reasons to change the vertex diffuse.

Anyway, yes it works. If you have a good use for it, then by all means use it.

##### Share on other sites
Great, and I was wondering when and where I should use those renderstates. Also, can they be a bottleneck? I will change them 10 times a frame, maximum.

So, in other words, I can combine DIFFUSE and NORMAL fvfs. I want to do that so I can select between vertex/normal lighting for my terrain engine (Remember the demo I uploaded several days ago here?)

Thank you