Jump to content
  • Advertisement
Sign in to follow this  

Advice on Opacity map with c#

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

Hi online. I need help on getting transparency right using opacity maps. I have tried looking around, but I can't seem to find an answere. I have made dinosaur model, which has a texture mapped onto it. I have a separate texture that represents the opacity map ( for things like his teeth ). How do I make direct x use the opacity map? What kind of render states and settings do I use? Is it something like this except using alpha values: device.RenderState.AlphaBlendEnable = true; device.SetTexture( 0, colourTexture ); device.TextureState[0].ColorArgument1 = TextureArgument.TextureColor; device.TextureState[0].ColorOperation = TextureOperation.SelectArg1; device.SetTexture( 1, opacityTexture ); device.TextureState[1].ColorArgument1 = TextureArgument.current; device.TextureState[1].ColorArgument2 = TextureArgument.TextureColor; alpha....? I don't know what to do. Could someone give me some advice? I have tried the examples in the DX documentation, but they didn't have what I was looking for. Thanks a million :)

Share this post


Link to post
Share on other sites
Advertisement
You can combine the textures into an alpha channel supporting format (like the native Direct3D format or .png) and then set the renderstates to

device.RenderState.SourceBlend = Direct3D.Blend.SourceAlpha;
device.RenderState.DestinationBlend = Direct3D.Blend.InvSourceAlpha;
device.RenderState.AlphaBlendEnable = true;

AFAIK, the texture tool that comes with the DX SDK provides functionality to merge an alpha bitmap (opacity map) with a texture.

Share this post


Link to post
Share on other sites
Thanks Enselic, I did that and it worked nicley :) Do you know what the SourceBlend and DestinationBlend properties actually mean? You see Im trying to get an effect; I want to have a sky texture and then use a separate texture which will represent clouds get put over that (and move). Now the cloud texture has an opacity map, but if I use your example it removes the sky texture behind it. I want the clouds to be placed over the sky without removing the sky texture. Any ideas? Thanks.

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!