transparent imposters

Hello,

I am creating imposters by rendering my objects to a texture, and then texturing a quad. I am wondering if there is a way to somehow mask the texture so that it is transparent where there is no object.

My thinking so far:

Blend the incoming texture color with the color of the quad. Then if the texture color is the same as the quad color, set the texture alpha to 0.

How do to this, i dont know. There doesnt seem to be any kind of blend function that would do this. Maybe an extension?

I imagine a pixel shader could accomplish this but my app doesnt support shaders…yet

any ideas?

You could first fill your imposter texture, so that the alpha channel is all 0. That means the whole texture would be invisible.
Then when you render your object into the texture, the alpha value of your texture gets set to 1, but only where your object was rendered to.
So, then you got a mask for your object.

When rendering your impostor, you use the alpha test, so that all fragments with alpha == 0 get discarded.

glEnable (GL_ALPHA_TEST);
glAlphaFunc (GL_GREATER, 0.0f);

That means only fragments with alpha > 0 pass the test.

You don´t need no blending at all for this. So it will be quite good for your fillrate.

Hope that helps you.
Jan.

Thanks alot!

That totally makes sense. I will give it a try, but I am sure it will work…