• Advertisement
Sign in to follow this  

smth's is wrong with material

This topic is 4279 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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 ) ;

Share this post


Link to post
Share on other sites
Advertisement
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.

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.

Share this post


Link to post
Share on other sites
You were right. My zNear was set to 0, I set it to 1 and it looks fine now, thanks.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement