Alpha blending and color keys

Started by
3 comments, last by fdisano 23 years, 9 months ago
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 ~----------------------------~
~----------------------------~ Fredola Coder by day Gamer by night Ottawa.CA~----------------------------~
Advertisement
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 ***
*** Triality ***
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
~----------------------------~
~----------------------------~ Fredola Coder by day Gamer by night Ottawa.CA~----------------------------~
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.
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

This topic is closed to new replies.

Advertisement