PDA

View Full Version : Who knows some instruction for transparent texture mapping?



warrener
02-25-2002, 09:00 PM
Who knows some instruction for transparent texture mapping?
I want to know some instruction for transparent texture mapping. I tried some bland command(glBlendFunc()) but it does not work so good.
For eg., You have two walls: A and B, both are transparent, you draw the A first and B second using glBlendFunc(), and the A is NOT transparent http://www.opengl.org/discussion_boards/ubb/frown.gif

So, I need some REAL transparent command.
Thank you very much

JML
02-25-2002, 11:14 PM
Originally posted by warrener:
Who knows some instruction for transparent texture mapping?
I want to know some instruction for transparent texture mapping. I tried some bland command(glBlendFunc()) but it does not work so good.
For eg., You have two walls: A and B, both are transparent, you draw the A first and B second using glBlendFunc(), and the A is NOT transparent http://www.opengl.org/discussion_boards/ubb/frown.gif

So, I need some REAL transparent command.
Thank you very much

Well, this may not be really an advanced question, but anyways...

In order to correctly display multiple transparent objects with overlap, you should draw them in a depth-sorted order (back to front).
The transparent objects should be drawn AFTER all opaque objects have been drawn unless you can depth-sort these too.

There are techniques that allow correct rendering of transparent objects without performing the depth-sort, but these are harder and may involve using frame-buffers with alpha channels (not always available and not always high-performant).

HTH

Jean-Marc.

T2k
02-25-2002, 11:16 PM
ok thats easy:
1st you do something like:
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

then you draw your walls, but look at the command leading the drawing
glColor4f(1,1,1,0.75f);
//draw wall1
glColor4f(1,1,1,0.25f);
//draw wall2

i think depth isnd the problem (sorted from back to front) else disable depth writes (not tests !):
glDepthMask(GL_FALSE);

now you want to know why the color-command affects the objects ?? because each pixel is multiplied with this color-value ! and in this example you apply an alpha value of 0.75f or 0.25f which produces transparency (alpha 1.0f is solid )

pongsak.a
02-26-2002, 03:39 PM
Hope this help you. http://nate.scuzzy.net/gltut/colorkey.zip
Goodluck.