doubt in blending

i’m a newbie in Opengl and i have a doubt in blending. please tell if the procedure i follow is correct for blending. first i draw all the opaque objects and then in the last i draw the object to be transparent. I’m using GLUI for interface. so i have to check the state of the checkbox and enable and disable the blending. hence just before draw the transparent object (and after drawing the opaque objects), i check the state of the checkbox and enable blending.

here is the piece of code doing that:

glBlendFunc(GL_ONE, GL_ZERO);

now heres the problem, in the output, i see a additional black inner object(the one which is opaque).this black object is when i rotate the object when in blend mode, the black object interferes with the rotating opaque object.

I hope you understand what i mean. i think there must be something wrong in specifying the source and destination factors in glBlendFunc(). please tell me the error.


It seems globally corect.
But the change in glBlendFunc is not useful : leave it to src_alpha etc, if blending is disabled, blendFunc is not used.

One thing though : your transparent objects have to be drawn from back to front. Yes, it is a pain is the neck.
And why your alpha color is 0.5 ? why not 1.0 ?

For the problem with you ‘black object’, well I do not quite understand what you mean. You may draw it 2 times ?

Hope it helps.


actually, i kept the alpha value 0.5 to make the object appear transparent.

as for the black object, i tried glDepthMask(GL_TRUE) and it worked. the wierd black object just disappered. but how is this possible?

i just don’t understand. the glDepthMask() must be set to false so that the buffer is read only when rendering transparent objects. but if i keep it to false, i get that misterious black inner object(which is duplicate of the lit inner object). I just tried and kepth the glDepthMask to true and it worked out perfectly.

how is this possible??

… but how is this possible?

Well, I don’t know, you did not put your code or a screenshot to explain your ‘black ghost’ better, so…

For substractive transparency (your case), you do have to sort objects from back to front. Depth write should not be useful, but can limit sorting ‘bugs’.

If you just need additive transparency, it is much easier, no need to pre-depth-sort your transparent polys. Use ONE ONE for blendfunc.


sorry for not sending a pic.

here are the urls.i have to pics to make clear of what i’m saying:




i forgot to ask you something in the earlier post. what is subtractive and additive transparency? also is there some good resource on the net on blending? i’m particularly confused on how the source and destination factors in glBlendFunc() work.


in general, everything is right. if you first draw all solid faces with blending disablend and after that draw all transparent faces in back-to-front order with blending enabled, it should look fine. the black stuff rather looks like a culling problem.