Alpha Stuff

Started by
6 comments, last by evanofsky 18 years, 11 months ago
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!
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?
--X
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.
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.
Chris ByersMicrosoft DirectX MVP - 2005
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.
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
Not every paint programm understand alfa values and not everey file format supports alfa.
Try the png format, it will work fine...
*Los Brutalos*(Sorry for my brutal english ;)
w00t, I can't believe I didn't think to check the format first!! Thanks alot.

This topic is closed to new replies.

Advertisement