Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

v1nd1cat10n

Alpha Blending Insanity

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

I''ve been struggling with this for some time now (I''m not very good at asking for help). I''m doing a terrain texture using splatting from http://www.cbloom.com/3d/techdocs/splatting.txt I have 4 sets of textures. In each set the second texture is the terrain splat texture (i.e. grass,rocks,sand,snow, etc..) The first texture is an alpha map for the second texture. my code looks like this (C# Managed DirectX): device.RenderState.AlphaBlendEnable = true; device.RenderState.SourceBlend = Blend.SourceAlpha; device.RenderState.DestinationBlend = Blend.InvSourceAlpha; //Then we loop through the 4 texture sets { device.SetTexture(0,alphaTexture); device.SetTexture(1,splatTexture); device.TextureState[0].ColorOperation = TextureOperation.SelectArg1; device.TextureState[0].ColorArgument1 = TextureArgument.TextureColor; device.TextureState[0].AlphaOperation = TextureOperation.SelectArg1; device.TextureState[0].AlphaArgument1 = TextureArgument.TextureColor; device.TextureState[1].ColorOperation = TextureOperation.SelectArg1; device.TextureState[1].ColorArgument1 = TextureArgument.TextureColor; device.TextureState[1].AlphaOperation = TextureOperation.SelectArg1; device.TextureState[1].AlphaArgument1 = TextureArgument.Current; } What happens with this code is that the first texture set looks great with the right transparency etc, but I see no sign of any of the other texture sets. I can choose only to render one set (any of the sets) and it looks good so I know the other sets are good and the multiple stage texturing is working as planned. I just can only get one set to work. Can somebody let me know if I am screwed in the head thinking I can do it this way? I am doing multi-textureing (> 1 stage) AND multiple passes, is there a problem with this?? Help!! Thanks in advance

Share this post


Link to post
Share on other sites
Advertisement
There is a sample in the SDK called MFCTex. There, you can setup your texture stages and fiddle around with it's appearance in realtime. Then, it'll give you all the code you need to get the given appearance.

I suggest that you check that out, and make the textures look the way you want there. Then, take the code info it gives you, and put it in your app.

Edit: the config you have there seems to work okay


Dustin Franklin
Mircrosoft DirectX MVP

[edited by - circlesoft on June 5, 2004 7:00:58 PM]

Share this post


Link to post
Share on other sites
That looks okay (though I''d set stage 2 to DISABLE).

When you use just one splat, you say it''s fine, with the correct alpha, so we can assume your alpha textures really are alpha textures. After that, the only think I can think of that would stop multipass from working is if you ZFUNC is D3DCMP_LESS instead of D3DCMP_LESSEQUAL. You should make sure.

Multistage and multipass are completely seperate issues. You can mix them like you''re doing just fine.

If you have large areas where the alpha is 0, consider turning on alphatest with an alpharef of 0 (or something low, like 8) and an alphafunc of greater. This will save tons of memory bandwidth for each pixel it doesn''t need to alphablend.

Share this post


Link to post
Share on other sites
Thanks for the peace of mind that I wasn''t all screwed in the head. I have it working now. I added an initial pass of a base texture with Alpha Blending off before the blended textures. After that, everything else shows up correctly.

Does anybody know why that would be the case??

"It''s nice to be nice to the nice." - Frank Burns

Share this post


Link to post
Share on other sites

  • 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!