PDA

View Full Version : glBlendFunc(GL_HALF_SRC, GL_HALF_DST) ?



MickeyMouse
04-02-2002, 10:22 PM
hi!
maybe i ask for something obvious for some of you but how can i do the fastest way
blend colors of source pixels with destiny pixels like
result_color = (source_color + destiny_color) / 2 ?
is that possible without manipulating with alpha values for certain texels and with single pass texturing?
thx for help.

T2k
04-02-2002, 10:49 PM
i think its not so simple to do, because the blend func dont understand GL_HALF_SRC and GL_HALF_DST !!! you could do something like:
glBlendFunc(GL_SRC, GL_DEST);
glColor(1,1,1, 0.5);//the alpha value of the current color is multiplied with alpha of texture, so you get source_color*0.5= source_color/2 !

but you only get:
source_color/2 + dest_color

you cannot do something similar with the dest color http://www.opengl.org/discussion_boards/ubb/frown.gif ...

MickeyMouse
04-02-2002, 11:07 PM
thx
but still what is the way (any way) to achieve that effect?
i don't undestand it at all why OpenGL doesn't have blend function that would simply get the average value of source and destiny - isn't it very common for our real world (the one not in the screen), that we face some materials making all behind it twice less visible?:
(src_color + dest_color) >> 1 is implemented very fast

i think this could be useful too if OpenGL had something like parametrized(?) blending function taking two values and resulting in
src_color * src_given_value + dst_color * dst_given_value
although i know this could be very slow (on present video processors i guess 2 * mul > 10 * add)

Humus
04-02-2002, 11:41 PM
glColor4f(1,1,1, 0.5f);
glBlendFunc(GL_SRC_ALPHA, GL_SRC_ALPHA);

should work