Jump to content
  • Advertisement
Sign in to follow this  
Juksosah

Working with sprites transparency issues.

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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 ?

Share this post


Link to post
Share on other sites

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.

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.

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!