PDA

View Full Version : Blending causes unexpected effect



Seishin
08-22-2012, 01:26 PM
Hi all,
I'm trying to enable blending to make sphere transparent.
But when I enable it, the effect below occurred.
http://s8.postimage.org/enh1i4rp1/Untitled.png
The dividing line appears even if I use lighting. (Currently I just use glColor and disabled lighting.)
Does anyone know the reason? Thanks.

Here are some related code:
One of the spheres which rotating around center:

glColor4f(1.0, 1.0, 0.0, 0.6);
glPushMatrix();
glRotatef(angle, 0, 1, 0);
glTranslatef(0.0, 0.0, 1.0);
glScalef(0.3, 0.01, 0.3);

glEnable(GL_NORMALIZE);
GLUquadricObj *qobjSphere;
qobjSphere = gluNewQuadric();
gluQuadricDrawStyle(qobjSphere, GLU_FILL);
gluQuadricNormals(qobjSphere, GLU_SMOOTH);
gluSphere(qobjSphere, 1, 100, 100);
glPopMatrix();
Enable blending:

glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_DEPTH_TEST);

Seishin
08-24-2012, 06:51 AM
http://s15.postimage.org/x5op53yt7/Untitled2.png
This is the effect of two gluDisk get intersected. I think they got the same problem.
I tried to enable and disable lighting, depth buffer and culling, but nothing changed.

Seishin
08-31-2012, 10:11 AM
Has anyone met this kind of problem before?

V-man
09-01-2012, 05:00 AM
Search for z-fighting.
You can aleviate it a bit by setting glDepthFunc(GL_LEQUAL).