Sign in to follow this  
dmd_anfini

Texture Color Key without D3DXCreateTexture###

Recommended Posts

Hi, is there a way to add color key to a texture without using the functions D3DXCreateTexture####ex ? What is the magic behind these functions? When these functions are used, the resulted texture will be in the format we provided or will be reformatted to A8R8G8B8? Thanks

Share this post


Link to post
Share on other sites
1. D3DXCreateTexture***Ex() will indeed change the format of the texture as appropriate, and I suspect this includes changing it to one with an alpha channel (A1R5G5B5, A8R8G8B8, etc) if you request the colour key be used.
That's unless you specify D3DFMT_FROM_FILE of course...


2. The algorithm will be along the lines of:

for (every pixel in the image)
{
if (SRC.rgb == COLORKEY.rgb)
{
DEST.rgb = 0;
DEST.a = 0;
}
else
{
DEST.a = COLORKEY.a;
}
}



3. Colour-keys are an outdated concept* - just use an input file format that has an alpha channel and let the artists mark transparent areas properly (most proper paint programs handle alpha properly too).


4. To give you an idea of just how oudated, drivers for one card out in around 1999 used to emulate DirectDraw colour keying using 3D hardware and alpha blending.


[* before someone says 'chroma' I'm just talking about the lesser colour keying technique here]

Share this post


Link to post
Share on other sites
Thanks, just trying some old things http://www.gamedev.net/community/forums/images/icons/icon7.gif

I think that getting the surface from the texture and loading it with D3DXLoadSurfaceFromMemory along with colorkey, it will works. But if the format provided to createtexture and to D3DXLoadSurfaceFromMemory doesn't have an alpha channel, the resulted surface/texture will have a modified format?

Share this post


Link to post
Share on other sites

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