PDA

View Full Version : glBlendFunc ?!



Jnz86
05-29-2004, 04:39 AM
Hi,
i am having trouble understanding this fucntion: glBlendFunc, i know what it does, but i don't what parameters should i pass into this fucntions when i want to draw something like glass, blood and so on. I have read the official OpenGL documentation and it didn't helped. Can you post me a link to some kind of tutorial or such ?

ZbuffeR
05-29-2004, 05:53 AM
For quick blend tests I use ParticleBlend you can find at http://www.int03.co.uk/crema/software/index.html , not the best way (no textures) but not too bad.

The most useful modes are :
- additive transparency : order independant, mostly useful for fire particules, lightnings, lensflares, etc. Some games use it for particles systems of dust or clouds, because there is no sorting necessary, it is not physically correct, but may be visually acceptable.
glBlendFunc( GL_SRC_ALPHA,GL_ONE);

- normal transparency : order DEPENDANT, should be drawn from far to near. For all the normal overlaying stuff (blood splatting, etc). In practice, for drawing cars for ex, you can forget the ordering, as each car glasses are convex, and it is rare that you see a glass car trough another glass car. You can sometimes spot such simplifications in Quake3 or many other games if you are very careful.
glBlendFunc( GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);

- more or less interesting effects :
substractive effect, maybe for painted glass ?
glBlendFunc( GL_ONE_MINUS_DST_COLOR,GL_ONE_MINUS_SRC_COLOR);
a negative effect, quite nice against a white background :
glBlendFunc( GL_ZERO,GL_ONE_MINUS_SRC_COLOR);