smth's is wrong with material
Hi, As you can see in images (img1 img2 img3), there is some kind of diffusion or smth when one side of object covers another side, is there a way to avoid this? my light setup is as folloows:
GLfloat materialDiffuse[] = { 1.0, 1.0, 1.0, 1.0 };
GLfloat materialSpecular[] = { 1.0 ,1.0, 1.0, 1.0 };
GLfloat materialAmbient[] = { 0.2 ,0.2, 0.2, 1.0 };
GLfloat materialEmission[] = { 1.0 ,1.0, 1.0, 1.0 };
GLfloat materialShininess[] = { 100 };
GLfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 };
// setup material settings
glMaterialfv( GL_FRONT, GL_DIFFUSE, materialDiffuse );
glMaterialfv( GL_FRONT, GL_SPECULAR, materialSpecular );
glMaterialfv( GL_FRONT, GL_SHININESS, materialShininess );
glMaterialfv( GL_FRONT, GL_AMBIENT, materialAmbient );
glMaterialfv( GL_FRONT, GL_EMISSION, materialEmission );
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
// enable lighting
glEnable( GL_LIGHTING );
glEnable( GL_LIGHT0 );
glDepthFunc( GL_LEQUAL );
glEnable( GL_DEPTH_TEST );
glEnable( GL_AUTO_NORMAL );
glEnable( GL_NORMALIZE );
glColorMaterial ( GL_FRONT_AND_BACK, GL_EMISSION ) ;
glEnable ( GL_COLOR_MATERIAL ) ;
The pictures look like a classical case of Z-fighting. To correct this you might try to adjust the z-near and z-far values for the clipping planes or you can use glPolygonOffset.
Here's some more information: http://www.opengl.org/resources/faq/technical/depthbuffer.htm
Also, unless you're rendering maps using glEvalCoord, the glEnable(GL_AUTO_NORMAL) will do nothing.
Here's some more information: http://www.opengl.org/resources/faq/technical/depthbuffer.htm
Also, unless you're rendering maps using glEvalCoord, the glEnable(GL_AUTO_NORMAL) will do nothing.
Quote:http://developer.3dlabs.com/documents/GLmanpages/glevalcoord.htm
If automatic normal generation is disabled, the corresponding normal map GL_MAP2_NORMAL, if enabled, is used to produce a normal. If neither automatic normal generation nor a normal map is enabled, no normal is generated for glEvalCoord2 commands.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement