PDA

View Full Version : Blend and lighting problems: the blending function doesn't work after rotation...



Sumiko
1st May 2013, 00:15
Hi,

I am working for a 3D surface rendering of a tube. The rendering function works good when the rotation angle rotX(in x direction) and rotY(in y direction)
is between -90 to 90 degrees, when they are between 90 to180 degrees, the 3D tube can not be blended...

9000 <== Blended, when rotX and rotY between -90 to 90 degrees.

9001 <== not blended, when rotX or rotY between 90 - 180 degrees.

the FOV is set as glOrtho(-128, 127,-128, 127, -50, 49);

The following is the lighting and blending setting in initializeGL();

void GL_Widget::initializeGL()
{

qglClearColor(Qt::black);
/* ------ Lights ------ */
//Light Point Source
GLfloat light0_position[] = {-128.0f, 0.0f, 0.0f, 1.0};
GLfloat light0_ambient[] = { 0.8f, 0.28f, 0.28f, 1.0f};
GLfloat light0_diffuse[] = { 0.20f, 0.20f, 0.20f, 1.0f};
GLfloat light0_specular[] = { 0.8f, 0.8f, 0.8f, 1.0f};

glLightfv(GL_LIGHT0, GL_POSITION, light0_position);
glLightfv(GL_LIGHT0, GL_AMBIENT, light0_ambient);
glLightfv(GL_LIGHT0, GL_DIFFUSE, light0_diffuse);
glLightfv(GL_LIGHT0, GL_SPECULAR, light0_specular);


GLfloat light1_position[] = {127.0f, 0.0f, 0.0f, 1.0};
GLfloat light1_ambient[] = { 0.8f, 0.28f, 0.28f, 1.0f};
GLfloat light1_diffuse[] = { 0.20f, 0.20f, 0.20f, 1.0f};
GLfloat light1_specular[] = { 0.8f, 0.8f, 0.8f, 1.0f};

glLightfv(GL_LIGHT1, GL_POSITION, light1_position);
glLightfv(GL_LIGHT1, GL_AMBIENT, light1_ambient);
glLightfv(GL_LIGHT1, GL_DIFFUSE, light1_diffuse);
glLightfv(GL_LIGHT1, GL_SPECULAR, light1_specular);

//Material
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 45.0);
//Shading
glShadeModel(GL_SMOOTH);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER,GL_FALSE );
//Enable Lighting
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_LIGHT1);
glEnable(GL_COLOR_MATERIAL);

glEnable(GL_NORMALIZE);
glEnable(GL_DEPTH_TEST);
}

Is any ideas or advise about this issue? is it a drawing ordering issue or just depending the lighting and blending function? Thank you in advance!

wysota
1st May 2013, 19:03
Why are you asking that question here and not on some OpenGL forum?

Sumiko
1st May 2013, 20:17
thanks! I have asked in OpenGL forum too. but I could not post my code there, I am not sure why...

wysota
1st May 2013, 21:44
Maybe the forum software is smart enough to determine your problem is unrelated to Qt :)