Game Development Community

Dealing w/ alpha channels in T2D

by Alex Rice · in Torque Game Builder · 09/10/2005 (9:38 am) · 2 replies

I can't figure out how to get at that alpha channel at runtime. There seems to be no way to find out if a particular point is in a region of the sprite that has 0% alpha channel. Or any per pixel maninuplation yet (have read Melv's posts about that)

I am going to have mask sprites with cut-out shapes on them and the player is going to be clicking on those transparent areas to get at the stuff underneath. In some cases I think I can just figure it out using a collision poly to overlay the transparent area. But some of these cut-out-shapes will be more complex and concave.

It would be useful if all the pick*() functions had a boolean parameter whether or not to consider the alpha channel. If it finds 0% alpha then the function would discard that object from it's result list. Or it could be a % value for the threshold of alpha to consider.

If there is no way to get at this info at runtime I guess I have to create a tile map that approximates the shape of the "cut-out" but that would be very time consuming.

Anyone else run into this problem?

#1
09/10/2005 (10:22 am)
Yeah, sorry, there is no picking on a texel-by-texel basis. Picking is done via collision polygons. One option, although pretty tedious to set up, is to create a series of "sprites" that all use an invisible 1x1 image map each with a convex collision polygon. If you link all of these sprites to a parent "sprite" you could build an arbitrary, non-convex shape (in geometric terms, polygons are convex or non-convex, they are generally not called concave).

Another option, although this would be engine modification, would be to have your shape render to the stencil buffer and then check the stencil buffer to see if you are picking the shape. This would allow you to have up to 256 "pickable" objects per frame with true, per-pixel picking, but it would be a bunch of coding. I saw another post around here that had Matthew Kee utilizing the stencil buffer for his UI project, so it's not impossible. You might want to ask Matt how he did it.
#2
09/10/2005 (10:33 am)
Jason- OK thanks for the feedback. I don't know C++ or OGL that well, so collision poly's it is. I think Tile Map will help in this situation :-)