PDA

View Full Version : Blending and Color-Arrays!!!!



Phoenix
03-31-2002, 09:54 AM
I have a tricky problem with Blending: I have stored a 3D-Object in a data-structure containing coordinates, normals, texture-Coords, and COLOR for *EACH* vertex. Then I just use Vertex-Arrays (glDrawArray) to display the entire object...the problem is that I want to make the object TRANSPARENT. it sounds very simple but things become (for me) very hard when I discovered that I cant just use glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) because the COLOR-ARRAY contains RGB values and so, the ALPHA value for each vertex will be ALWAYS set to 1.0!!!
So how can I blend an object with RGBA COLOR-DATA still defined for each vertex???????

I have to say also an important thing: to avoid this problem I have tried to set BlendFunc(GL_DST_COLOR, GL_ZERO) then I set the current color to (1.0, 1.0, 1.0, ALPHA) and render the entire geometry of the object with texturemapping and all the other stuff DISABLED! Then, I made a second-pass in which I enabled texture map and rendered the object with glBlend(GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA)... I cant understand why, but this method simply DOESN'T WORK!!! ?!?!?!?! ... some people told me that some gfx-cards dont support DST_ALPHA :-?.....Can you give me any suggestion please?? I dont how to solve this problem.
THANX!

davepermen
03-31-2002, 11:39 AM
set an alphavalue per vertex.. if you dont want that.. uhm...

use texture env and set the alpha there to the constant-color you can set there (if you can..)

depends on gpu, but should be possible on most gpu's.

but you will get errors as long as your mesh is not z-sorted anyways..

Phoenix
03-31-2002, 02:07 PM
Your answer seems to be the only interesting one that I received till now...but I still have some doubts about your solution because I fear not to have understood it well...
Could you explain better the story of the texture env?? thank you a lot!!

genglish
03-31-2002, 06:59 PM
EXT_blend_color will let you give a specific color to be used in the blend equations:
(From nVidia but ATI also supports it): http://www.nvidia.com/dev_content/nvopenglspecs/GL_EXT_blend_color.txt

Give the blend color and alpha and you should be fine. ( I haven't actually tried this yet though ... )

Good luck,
Guy

genglish
03-31-2002, 07:06 PM
I may have spoken too soon about ATI supporting EXT_blend_color. I can't see it on this page: http://www.ati.com/developer/sdk/radeonSDK/html/info/Prog3D.html

Humus
04-01-2002, 05:37 AM
That list is incomplete, GL_EXT_blend_color is supported. That list has only like 50 extensions listed, but the latest drivers have support for 67 extensions.