Jump to content
  • Advertisement
Sign in to follow this  
stenny

multiple colour keys

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

Hey Gamedev! I was wondering is there was a way - apart from using the alpha channel in the file itself - to add multiple colour keys to a texture. I know you can add one with D3DXCreateTextureEx, but this limits the number of keys to only one. Is there a way? /Stijn

Share this post


Link to post
Share on other sites
Advertisement
I'm pretty sure D3DXCreateTextureEx uses the alpha channel to do color keying. That is, when you pass a color key to the create function it runs through the image, and all pixels with the given color has it's alpha set to 0. So if you want to have multiple color keys you can manually, at load time, do a pass over the pixels of the image and set the alpha to 0.

Alternativly, write your pixel shader to replace the alpha of samples matching your color keys' with 0 when sampling the texture.

Share this post


Link to post
Share on other sites
Since colour keying isn't natively supported in Direct3D, you'd have to use the alpha channel.

Assuming there's no overlap between the colour keys (i.e., normal usage), you could use a different alpha value for each of them, then enable alpha testing and set D3DRS_ALPHAFUNC to D3DCMP_NOTEQUAL and D3DRS_ALPHAREF to the value you want to key out.

Share this post


Link to post
Share on other sites
Sign in to follow this  

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