Jump to content
  • Advertisement
Sign in to follow this  

asign alpha color to specific color in mesh

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

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
Sign in to follow this  

  • Advertisement

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!