asign alpha color to specific color in mesh

Started by
0 comments, last by jollyjeffers 18 years, 10 months ago
how can I put the alpha color to a mesh ??? or how can I put the alpha color to a mesh but just to a especific color of the mesh????
Advertisement
This can be done, but we need a bit more information first [smile]

I'm not too sure what you mean by the "to a specific color of the mesh" though.

I will be assuming a ID3DXMesh here.

A typical mesh loaded from a .X file will have position+normal+texcoord format; the fact that it has normals is usually an indication that you'll have to be using fixed-function (or your own shader-based) lighting.

This makes things a little bit more tricky.

If you want to stick with having a "lit" mesh then you have these options:
- adjust the D3DMATERIAL9 objects accordingly, but any change here will affect all the geometry in the given attribute. That is, it doesn't give you fine per-vertex (definitely not per-pixel) control over the alpha.
- Mess with ID3DXMesh::CloneFVF() and add a D3DFVF_DIFFUSE component in, and I think (not sure) you'll need to tweak some of the render states.

If you're happy providing the lighting yourself, or you're just simply not using the "traditional" lighting models follow the second idea above - Clone the mesh and then specify your own diffuse colour on a per-vertex basis.

Alternatively, if you don't want to be operating on the per-vertex level, and you're actually wanting per-pixel control over the alpha you need to look into modifying the textures that are mapped to your mesh. In particular, make sure they have an alpha component that is filled with the appropriate value.

This last possibility can be done in a huge number of ways - the specifics all depend on how complicated you can handle (or need!) and what exactly you're using the end-result for (e.g. if it's static or dynamic).

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

This topic is closed to new replies.

Advertisement