Define vertex format diffuse as floats 0.0f - 1.0f

Started by
1 comment, last by Namethatnobodyelsetook 18 years, 10 months ago
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
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.
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.

This topic is closed to new replies.

Advertisement