Arbitrary (variable) Transparency of a texture-mapped quad? (Please Help)

Hi,

This is mostly a pure OpenGL question, and I’m sure I could eventually figure it out, but I am under time pressure, and I would like some input on how to achieve the following: I have a quad which is texture mapped (e.g. with a PNG) which already contains variable transparency, i.e. an object and, for exmaple, it’s shadow (and it’s of an irregular “shape” (opaque pixels) to begin with.

What I need to do, is render this object with variable transparency (i.e. scale the entire alpha channel) at runtime, i.e. without modifying the texture. For example, to have the object flashing smoothly, or fading in/out. My suspicion is that I can achieve this by altering the alpha component of the “colour” of the quad being drawn, and then tweaking the blending and texturing modes (i.e. using GL_MODULATE or something like that, instead of GL_DECAL).

Could anybody give me any pointers? And (the big “if”): Would I be able to achieve this using the JOGL Texture utility classes (which are already servign me well in dealing with non-power-2 textures) or would I need to take a look at the source code, and either implement my own, or subclass them if necessary? I would prefer to stay at a higher level of abstraction, i.e. as said, to deal with things like texture dimensions. (I don’t want to re-implement it all in OpenGL calls if possible)

thanks for any help,
Dawid

By default the texture colour is multiplied by the (interpolated) vertex colour, so you should be able to just change the vertex alpha to achieve what you want. (ie. glColor4f(1, 1, 1, alpha) just before drawing it). Or have I missed the point? (default blending and texturing modes should be fine for this IIRC).

You’ll want to be careful with non-PO2 textures though, support for them is limited and even then it tends to be somewhat slower than regular PO2 textures. If you’re particularly unlucky you’ll get a card which will apparently support it but actually fall back to a (hideously slow) software method.

Hi! I’ll try just setting the vertex colours, thanks. As for the PO2 textures, I am weary for problems, yes, but I must say they’ve been working great thus far (admittedly, both ATI cards, but the one on the Windows machine an older one) - and updates have been very fast, more than suitable for DVD video.

Will let you know the outcome,
Dawid

Hi,

Thank you, just setting the colour worked great. It’s so obvious now that I think of it, but I did not realise the alpha is automatically premultiplied with the interpolated vertex alpha.
I really appreciate it, this is a great forum.

Dawid