Archived

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

Cybertron

Color-Key type of question

Recommended Posts

Cybertron    122
I am using a back color key to draw textures in D3D7, but my problem is there is always ugly black areas around it I looked in Unreal Tournament, and there is no such back areas, but in my game there are! (the textures are the same, heheh) How should I use color keying in D3D without the black areas? Additive blending could work for explosions, because they are sources of light. How would I enable additive blending?

Share this post


Link to post
Share on other sites
S1CA    1418
1. Use alpha-test instead of colour keying! The effects of filtering on the colour key will affect you. Even plain alpha is good.

2. A lot comes down to what the source texture looks like - the colours of the pixels in the transparent and translucent areas should be similar to those of the opaque pixels rather than all black! For example if you were to do an alpha channel for one of the smileys on here: the area around the outside of the circle should be YELLOW - with only the alpha values controlling opacity.

3. Additive blending is enabled like this:
Set the D3DRS_SRCBLEND and D3DRS_DESTBLEND renderstates to D3DBLEND_ONE and then enable alpha blending.

--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

Share this post


Link to post
Share on other sites
Cybertron    122
Thanks for the response! So I guess that means I need to add alpha-channel support to my game, Im sure that will improve the looks alot. I odn''t knopw if you can use alpha channels in 16-bit textures though. What does alpha-testing do in relation to masking out areas.

I say we just assimilate you into the Borg Collective, then our knowlage will become one....

Share this post


Link to post
Share on other sites
S1CA    1418
The D3DFMT_A1R5G5B5 format is widely supported and has just a single bit of alpha which is perfect for keying type situations.

You can then set up the alpha test operation and reference value so that it succeeds if ALPHA!=0. [i.e. opaque pixels get rendered].


--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

Share this post


Link to post
Share on other sites
Cybertron    122
Once I finish implementing alpha-channels I will write a new blit function to scale down 8-bit alpha into 1 bit, then disable this crappy color keying

I have one class for each file format which interits a generic interface. I have a pointer to the interface and can read any suppored file format just by using the Load() function after creating the specific class. cool eh?

EDIT: Works perfectly


[edited by - Cybertron on May 6, 2002 4:18:17 PM]

Share this post


Link to post
Share on other sites