Archived

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

fdisano

Alpha blending and color keys

Recommended Posts

Hey....I''ve got a couple of question to pose to ya''ll and no doubt someone out there has been through this shite already. 1) I''ve added a texture onto a poly and would like to control the level of transparency of the texture for all 255 levels of alpha. What''s the best way to do this? 2) I''m trying to set the colorkey value of the texture surface by calling the SetColorKey method. However, I''m having a little trouble understanding how the DDCOLORKEY parameter works. Specifically what is the significance of the dwColorSpaceLowValue and dwColorSpaceHighValue. Thanks ~----------------------------~ Fred Di Sano System Programmer Artech Studios Ottawa.CA ~----------------------------~

Share this post


Link to post
Share on other sites
1) Change the alpha component of the diffuse material to the level of transparency you want (0-full transparent, 1-opaque).

2)The low and high space values define the range of transparent colors. If you want black to be transparent then just set them both to 0.

*** Triality ***

Share this post


Link to post
Share on other sites
1) I set the diffuse ambient level but that did nothing, I think I also have to set a texture stage state for that as well no?

2) It seems to only filter out black (both values set to 0) anything else just doens''t work. I guess some hardware only supports colorkeying color 0?



~----------------------------~
Fred Di Sano
System Programmer
Artech Studios
Ottawa.CA
~----------------------------~

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
1) In order to use alpha blending, you must enable it and set it to the diffuse alpha:

lpd3dDev->SetRenderState (D3DRENDERSTATE_ALPHABLENDENABLE, TRUE);
lpd3dDev->SetRenderState (D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA );
lpd3dDev->SetRenderState (D3DRENDERSTATE_DESTBLEND,D3DBLEND_INVSRCALPHA );

Then set what alpha you want to use (diffuse in this case):

lpd3dDev->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
lpd3dDev->SetTextureStageState (0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE); // Put in D3DTA_TEXTURE if you specify a value in the texture.

I think that this should work.

2) It won''t use anything else because I think that any color other than 0 is for palettized modes only.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Actually color keys will work with any color not just color 0.However you have to make sure that the D3DCOLOR you specify is in the correct pixel format for the surface

Color keys are not really recommended though because they are emulated in a lot of frivers by using an alpha channel.For best results on newer cards you should probably use a surface with an alpha channel.This also gives you the flexablility of each pixel in the surface could have a unique translucency level,

Theres a tutorial that covers this stuff really well over at www.mr-gamemaker.com

hope this helps

Share this post


Link to post
Share on other sites