Jump to content
  • Advertisement
Sign in to follow this  
evanofsky

Alpha Stuff

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

How can you tell if a texture is at least partially transparent? Is there any easier way than just brute-forcing it and looping through every pixel on the texture and seeing if it has some transparency? Thanks!

Share this post


Link to post
Share on other sites
Advertisement
Im not sure really what the question is, nor if I can answer it heh. But im sure if you can tell what your objective is, maybe sum1 with some more experience can help ya out... If its for a pixel shader, its going to go through them all anyways, so there would be no need to brute force go through them all, all over again... Essentially thats my point heh. What do ya need it for?

Share this post


Link to post
Share on other sites
Maybe you could do the transparency check as a pre-process. In your resource structure that loads all your textures, have a bit that indicates whether it has any transparency. I'm assuming you're trying to save speed on renderstates.

Share this post


Link to post
Share on other sites
Perhaps an easier method would be to have the programmer pass in a boolean value indicating whether or not the texture is to be rendered with alpha. If the textures are loaded by an editor at design time, the editor could figure out if the texture is alpha or it could be a checkbox on the editor. Then it could be stored in a database. Lots of ways to do it, just trying to throw more out there.

Share this post


Link to post
Share on other sites
Yeah, the idea was to figure out if a texture was transparent when the texture was loaded. Then each "Texture" object would have a boolean value indicating if it was transparent or not. I was hoping to be able to do it without writing an image editor or anything... like the artist could use any image editor he wanted, and the program could figure it out on its own.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
To check if the texture has transparency you need to inspect the texture format..
Under directX you can use the D3DFORMAT to determine if the texture being loaded has transparency information (alpha channel).
A8R8G8B8 = 32bit texture with alpha
X8R8G8B8 = 32bit texture no alpha

Share this post


Link to post
Share on other sites
Not every paint programm understand alfa values and not everey file format supports alfa.
Try the png format, it will work fine...

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!