PDA

View Full Version : Subtractive Blending using GLblendFunc



alpha
02-23-2012, 10:33 PM
Hi. I would like to know how to make a scene darker using GLBlendFunction. I wan to add in a layer above the scene to make it darker. What GLBlendFunc can i use for this ?

Thanks

arekkusu
02-23-2012, 10:50 PM
See glBlendEquation, with GL_FUNC_SUBTRACT.

alpha
02-23-2012, 11:38 PM
Is there any other way without the use of glblendEquation ?

Alfonse Reinheart
02-24-2012, 12:47 AM
Is there something wrong with glBlendEquation? That's generally how you set up different blending equations.

And no, if you want to actually subtract color, then you must use glBlendEquation. You can make a scene darker just by doing traditional alpha blending with black, but that is not even remotely close to how it works physically.

alpha
02-24-2012, 06:17 AM
i see. I am not too sure that opengles for android offers glblendequation . So am looking for other approchs.

Does these
glBlendFunc( GL_DST_COLOR, GL_ONE_MINUS_SRC_ALPHA );
with dark color rectangles stimulate the scene darkening ?

Alfonse Reinheart
02-24-2012, 09:43 AM
Then you should have mentioned that you were using GL ES. Did you read the Posting Guidelines? (http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=305969&an=2#Pos t305969)

In any case, ES 2.0 does have glBlendEquation. ES 1.1 does not, but it does have an extension for it (http://www.khronos.org/registry/gles/extensions/OES/OES_blend_subtract.txt). So you can check the hardware you're interested in to see if it is worthwhile.


with dark color rectangles stimulate the scene darkening ?

That's a nonsensical blend mode. If you want to multiplicatively darken the scene by some value, put that value in the alpha and do:

glBlendFunc(GL_ZERO, GL_SRC_ALPHA);

alpha
02-25-2012, 04:10 AM
ic . I am currently working on a windows version using opengl before i port to mobile. So am looking on a future basis.

Will try the using the alpha values.