Sign in to follow this  

asign alpha color to specific color in mesh

Recommended Posts

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????

Share this post

Link to post
Share on other sites
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).


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