Sign in to follow this  

Why am I getting a wrong color with blend mode enabled?

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

Hi. I've been working on a simple line draw and I can't get the colors to work. I want to draw a red line. This is my result:

 

VZnl3.png

 

I have defined two vertices with the same color (red with an alpha of 255). As you can see source color is completely black. If I disable blend mode, I'd still get this result, but if I enable it and play with D3DRS_SRCBLEND and D3DRS_DESTBLEND, I can change the result, but it never gets to the point that I want which is a full red line.

 

My vertex format is as follows:

 

D3DFVF_XYZ | D3DFVF_DIFFUSE

 

Someone said that it might be from vertices normal vectors, but I don't have any lighting in my scene so it's not that. However, if I change D3DFVF_XYZ to D3DFVF_XYZRHW and pass value 1 for rhw, it'll draw the line with correct color, but that's not the format I want. I want to be able to apply geometry changes to my vertices and I know RHW does not receive any of that. And, I have a totally bright material and even if I set D3DMCS_COLOR1 for D3DRS_DIFFUSEMATERIALSOURCE, I'd still get the same result in the picture above.

Share this post


Link to post
Share on other sites

It sounds like your input layouts might not be correct. That its expecting a float4 for the position but you are only giving it a float 3 or the other way around, so the vert color is not looking at the correct memory.

 

Check your input format and how you have your vertices packed.

Share this post


Link to post
Share on other sites

Hey thanks. I don't know why I didn't think of that in the first place. I was setting a wrong offset in SetStreamSource(). Thanks again.

Share this post


Link to post
Share on other sites
Sign in to follow this