Sign in to follow this  

multiple colour keys

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

This topic is 3459 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this