Sign in to follow this  
dali

Take diffuse vertex color?

Recommended Posts

Hello! I am a bit ashamed to ask this but how can i take the vertex diffuse color instead of the diffuse material color. I think i have set all the renderstates correct:
device->SetRenderState( D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_COLOR1  );
device->SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_SELECTARG2);
device->SetTextureStageState(0,D3DTSS_COLORARG2,D3DTA_DIFFUSE);
device->SetTextureStageState(0,D3DTSS_COLORARG1,D3DTA_TEXTURE);   //Ignore 
device->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
device->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
device->SetTextureStageState(2, D3DTSS_COLOROP, D3DTOP_DISABLE);
device->SetTextureStageState(2, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
The vertex format looks like that:
struct VERTEX
{
	FLOAT x, y, z;
	FLOAT nx, ny, nz;
	DWORD color;
	FLOAT u, v;
};
#define D3DFVF_VERTEX (D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_DIFFUSE|D3DFVF_TEX1)
I cant see what is going wrong here. Another question is how i can unset the material for it is not possible to do something like device->SetMaterial(NULL); Thanks a lot!!

Share this post


Link to post
Share on other sites
If you're not using lighting, it will just use the vertex color.

If you're using light, you set the DIFFUSEMATERIALSOURCE that you've set, but you have to enable all the *MaterialSource states with D3DRS_COLORVERTEX. The diffuse color your stages will see will be a mix of light colors, vertex color, emissive, and ambient colors.

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