PDA

View Full Version : Semi-transparent texture



devdept
09-21-2008, 02:57 PM
Hi again,

Suppose you want to draw a white text using a texture on a blue QUAD rectangle.

We tryed making a white text on transparent background image and using the blue color for the QUAD object but the white color was affected by the blue one.

Then we tryed making an image with the white text on a blue backgroud and drawing the QUAD with white color, the result is better but the blue color is not reflecting light exaclty as all the other (non textured) QUAD with the same RGB color.

What is the best apprach to achieve a perfect result?

Thanks in advance,

Alberto

Ilian Dinev
09-21-2008, 03:45 PM
Perhaps...
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

:D

Well, you can use GIMP or Photoshop, see the different blending modes - and pick the one you like. Or code a shader to draw the text on blue background (blending disabled), but with some custom color-blending in the code.

devdept
09-22-2008, 01:38 AM
We are usign standard blending, no changes with glBlenFunc() so exactly what you suggested and the result is what I described.

Honestly I didn't wanted try every blend mode combination.

Thanks,

Alberto

yooyo
09-22-2008, 03:10 AM
Honestly, you should read manual before...

devdept
09-22-2008, 03:15 AM
yooyo,

I will, if what I asked can be achieved. Do you know if it possible?

Thanks,

Alberto

sqrt[-1]
09-22-2008, 04:19 AM
From what I understand of your (poorly worded) question, you want to render the text with the quad in one pass.

You can do this with texture combiner state:
http://opengl.org/sdk/docs/man/xhtml/glTexEnv.xml

but honestly, it is much easier to do it in two passes.

First pass:
Render blue quad as usual

Second pass
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
Render white quad with alpha transparency texture.
glDisable(GL_BLEND);

devdept
09-22-2008, 04:42 AM
Mmm, nice I will try immediately the two pass solution.

Is the glTexEnv the more fast rendering option and the two pass the more simple to implement one?

Thanks a lot sqrt[-1]!

sqrt[-1]
09-22-2008, 05:27 PM
Yes glTexEnv would probably be a little bit faster - but not worth worrying about unless you are drawing 10000's of these things.