View Full Version : Silhouette style texturing

James Lohr
09-02-2009, 04:08 PM
Here's what I would like to do:

I have some texture which has an alpha layer. Let's, for argument's sake, say that it is an image of a tree with backround having an alpha value of 0.

Firstly, how would I go about drawing a silhouette of the tree? (i.e. discard actual texture RGB values in favour of some plain colour, but still use the texture alpha values).

Now, (and this is what I would actually like to do, but I'm hoping that if I know how to do the first, I can work this second bit out): how would I go about drawing an inverted silhouette. So, in the case of the tree, the result would be a tree-shaped whole with a solid "background" of some specified colour.

It needs to work for an FBO, so I'm not sure if using the stencil buffer is an option (unless you don't mind showing me exactly how to use a stencil buffer with FBOs :P).

Thanks in advance.

James A.
09-02-2009, 09:37 PM
Can you use fragment shaders?

All you need to do in that case is when you are performing the look-up for the texture, find out it's alpha value and colour the fragment accordingly.