Working with sprites transparency issues.

Started by
2 comments, last by freeworld 12 years, 11 months ago
Hi everyone,

I'm using DirectX9.0c (i know it's old now)
I'm not on my computer right now so I cant post code sorry.

I'm trying to use sprites which are basically textured quads that I photoshopped to make some parts of them transparent by filling them with a color (in my case green 0,255,0) and doing an alphatest on the pixels of that color to remove them.

It works, but frankly when i get close the borders of the sprite are too pixellisated. What I would like to achieve is a more photoshop like result, when you zoom-in you can see semi-transparent pixels that kind of blend with the background.

Is there a way to do this with DirectX?


Thank you.
Advertisement
You could just load the texture with an alpha channel instead of masking them. This would require useing an image format that supports an alpha channel... like png, tga or the various d3d formats. How are you loading your textures? Or if you're using a shader and really want to use the mask for transparency, you could several shades of a color to determine the amount of opaqueness.

ie... if (color = first shade) color.alpha = 0.75
[ dev journal ]
[ current projects' videos ]
[ Zolo Project ]
I'm not mean, I just like to get to the point.
Thank you for your reply,

I'm using TGA files, and I followed tutorials on the net, so I load my textures with the function D3DCreateTextureFromFileEx or something like that.

I could use an alpha channel and I'm sure it's not too hard to code, but how can I do it in photoshop ? I replace my green filling by something else ? Can I have more details ?
Is it too taxing for the memory to use alpha channel especially if I plan to use a bunch of textures ?

Thank you for your reply,

I'm using TGA files, and I followed tutorials on the net, so I load my textures with the function D3DCreateTextureFromFileEx or something like that.

I could use an alpha channel and I'm sure it's not too hard to code, but how can I do it in photoshop ? I replace my green filling by something else ? Can I have more details ?
Is it too taxing for the memory to use alpha channel especially if I plan to use a bunch of textures ?


In photoshop, just don't put anything were you want it to be transparent... start by making a blank layer that is transparent ofcourse. Also I tend to prefer png, files just because I've had random issues with keeping the alpha channel with tga files. Also make sure you're creating your texture with a format that supports an alpha channel... ie D3DFMT_R5G6B5, isnt going to preserve the alpha channel, instead use something like D3DFMT_A1R5G5B5, or D3DFMT_A8R8G8B8.
[ dev journal ]
[ current projects' videos ]
[ Zolo Project ]
I'm not mean, I just like to get to the point.

This topic is closed to new replies.

Advertisement