Jump to content
  • Advertisement

Archived

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

+AA_970+

d3dx colorkey problems

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

Hi, i tried drawing a sprite with a colorkey (bright pink (255,0,255)) in d3dx, but there is an outline (the same color as the colorkey) around the sprite. Is there a way to get around this, and is there another (better) way to achieve the results of colorkeying? I''ve read that there is a way to do colorkeying with alpha blending can someone explain how this is done. +AA_970+

Share this post


Link to post
Share on other sites
Advertisement
If you are using colorkeying then there is no way of getting rid of the outline. You can try to minimize the effect by using a colorkey as close to the background as possible. But it will still be there. (Note: The outline might not be visible on some cards, it depends on how colorkeying is treated in the card)

And yes there is a better way to achieve the results of colorkeying. And that is to use alpha blending (as you already knew). To do this your sprite image must be created with an alpha channel where the alpha is set to zero for the parts that should be transparent, and 255 for the opaque parts. Then you need to enable alpha blending which is done by making these calls

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

By the way the color (255,0,255) is purple not pink. Pink would be something like (255,128,128).

- WitchLord

Share this post


Link to post
Share on other sites
What software can i use to add an alpha channel to my sprites?

Also, i want my game to use both d3dx for users with 3d cards and direct draw (with Blt, BltFast, & Pixel Plots) for users without 3d cards. Will adding an alpha channel affect the sprite in direct draw mode?

Another Question , Is the alpha channel saved as part of the image along with the RGB values?



+AA_970+

Share this post


Link to post
Share on other sites
I''m pretty sure photoshop can save alpha channels for certain types of 32bit images. Though I''m not sure if it would be hard or not to read.

For supporting both users, you must do just that. Write two different loading and color keying functions depending on which rendering method they use.

Again, see note about photoshop. It will save alpha channels, but probably in their own format only. I''m not sure what other graphics format supports alpha channels and has an editing program to go with. Some people choose to make a regular bitmap, then have a separate bitmap and have it in only black and white. It would just be the alpha channel (this, in theory, wouldn''t take up much more space than having an all-in-one format) so you might want to look into doing something like that.

quote:
Original post by +AA_970+

What software can i use to add an alpha channel to my sprites?

Also, i want my game to use both d3dx for users with 3d cards and direct draw (with Blt, BltFast, & Pixel Plots) for users without 3d cards. Will adding an alpha channel affect the sprite in direct draw mode?

Another Question , Is the alpha channel saved as part of the image along with the RGB values?



+AA_970+


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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!