Messed up blending problem

Dear All,

I really need some help with blending and transparency, as I think I’m getting all confused with source/destination/materials etc.

I am trying to create a solid opaque object that is covered by a transparent object.

I first render the opaque object before rendering the transpareny object using the following, standard code:

//////////////////////////////////////////////////
matdiff[0] = 1.0f;
matdiff[1] = 1.0f;
matdiff[2] = 1.0f;
matdiff[3] = 1.0f;
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, matdiff);

<Use vertex array to draw opaque object>

matdiff[3] = 0.6f;
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, matdiff);

glEnable(GL_BLEND);
glDisable(GL_DEPTH_TEST);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);

<use vertex array to draw transparent object>

glEnable(GL_DEPTH_TEST);
glDisable(GL_BLEND);
//////////////////////////////////////////////////

This code all works ok, but I am a bit unhappy about the way the blending looks. The overlapping objects seem to glow (the colors I think are ‘multiplied’ together), so I started playing around with the Blending Function, which I simply changed to:

glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

This gives me what I want! The glow is gone, and the transparency looks great… Except for one little problem…

The triangles aren’t quite right - there is something wrong with the rendering of polygons, perhaps with depth testing I suspect (because it looks great from some angles, but then when I move it, there is a clear line afterwhich the rendering goes all funny).

Can anyone please help? Many thanks in advance!

Best wishes,

Anthony

heres a windows app i wrote a few years ago, that explains the math behind blending (it uses fltk so u might need that installed, not sure)
http://uk.geocities.com/sloppyturds/stuff/opengl_blending.zip