Game Development Community

Alpha Masking in TGB

by Jan Napitupulu · in Torque Game Builder · 09/28/2010 (10:39 am) · 3 replies

Hi there,

i know this topic has been discussed several times within the forum, but unfortunately I couldn't find anything suitable for my problem, which is:

I have two textures (of same size). One has a solid texture (with no alpha) and the other one defines a certain shape (e.g. a circle) by a solid color (with alpha outside of the shape). I want to merge the two texures so that the shape has the texture on it and outside of the shape becomes transparent.

I know that there is no native support for alpha masking in TGB, so how can I handle this issue? I have the TGB Pro license, so I have access to the source. After a little bit of research, OpenGL multitexturing appears to be the solution for my problem, but in a lack of OpenGL experience I have no clue where to step into the source to make the changes needed.

Can anybody give me some hints, tutorials or even better, some code snippets where and how to start?



#1
09/30/2010 (2:13 am)
I'd modify t2dStaticSprite to allow a separate alpha mask. You can then do your multi-texturing inside that class and render out the result in the rendering function.
#2
10/05/2010 (12:15 pm)
Hi William,

thanks for the hint. I've spotted the location and now it seems to work properly. :)


#3
01/01/2011 (10:19 pm)
Jan,

Care to share? I think a lot of folks would like to add that bit of code to the engine. :)