Jump to content
  • Advertisement
Sign in to follow this  
Halsafar

Define vertex format diffuse as floats 0.0f - 1.0f

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

Is there anyway to have in your vertex struct a diffuse which use's floats to define the colors as between 0.0f - 1.0f? Much like the lighting from DX9 use's diffuse, specular, ambient D3DCOLORVALUE structs which contains floats, I would like to include that in my vertex structures for use with per-vertex alpha value's that are between 0 and 1. Is this possible? Or, do I have to simply go ALPHA = alphaNumBetween0and1 * 255

Share this post


Link to post
Share on other sites
Advertisement
Well, most programmers prefer the D3DCOLOR format because it's 4 times smaller, which is very important in something as small as a vertex.

Here's a macro from the SDK to help you until you settle on another routine:

D3DCOLOR_COLORVALUE(r,g,b,a)
..defined as
D3DCOLOR_RGBA((DWORD)((r)*255.f),(DWORD)((g)*255.f),(DWORD)((b)*255.f),(DWORD)((a)*255.f))

Read more about here.

Share this post


Link to post
Share on other sites
If you use a vertex declaration instead of an FVF you can use 4 floats for diffuse, and they will be expected to be 0..1. I'm not sure if you can use this vertex declaration with fixed pipeline vertex processing, or if you're required to make a shader. It will definately need a shader capable card to use 4 floats, but whether or not you actually need to use a shader, I'm not sure. Should be quick enough for you to test out.

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!