• Advertisement
Sign in to follow this  

Alpha Map/Texture in MDX9

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

So I've been having difficulty getting a rudimentary alpha map to work correctly in managed DX9 with C#. My code programatically generates an alpha texture that is supposed to mask a primary texture (for terrain splatting). However, no matter what texture state settings I try it always shows up opaque. I was under the impression that frame buffer transparency and texture transparency were different and so I didn't NEED to enable the EnableAlphaBlend render state, but I did just in case. I've tried using the primary texture in the first stage and then tried to use the alpha from the texture in the second stage, nothing. I've tried using the alpha texture as the first stage and putting the primary texture in the second stage, nothing. Here is the basic block I've used:
// stage 0 gets set before this in a switch based on splat type

parent.device.TextureState[0].ColorOperation = TextureOperation.Modulate;
parent.device.TextureState[0].ColorArgument1 = TextureArgument.TextureColor;
parent.device.TextureState[0].ColorArgument2 = TextureArgument.Diffuse;

parent.device.TextureState[0].AlphaOperation = TextureOperation.SelectArg1;
parent.device.TextureState[0].AlphaArgument1 = TextureArgument.TextureColor;

parent.device.SetTexture(1, s.AlphaMap);
parent.device.TextureState[1].ColorOperation = TextureOperation.Disable;
parent.device.TextureState[1].AlphaOperation = TextureOperation.SelectArg1;
parent.device.TextureState[1].AlphaArgument1 = TextureArgument.TextureColor;
parent.device.TextureState[1].AlphaArgument2 = TextureArgument.Current;
This seems theoretically correct but I may have overlooked some important detail. My graphics card (rage mobility-m) is quite old, but it reports MaxSimulataneousTextures to be 2, so that shouldn't be a problem. D3DPTEXTURECAPS_ALPHA is true. D3DSpy reports the generated textures are indeed A8R8G8B8 and that they are filled with the correct (or at least different, non-opaque) alpha values. I figure this must be a fairly simple fix, so any guidance would be greatly appreciated since I've been banging my head against this for a few hours.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement