Jump to content
  • Advertisement
Sign in to follow this  
ra1024

OpenGL Distortions around face intersections

This topic is 4848 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

I'm new to opengl and have been working rendering 3d models. Everything works fine but I'm seeing some distortions where faces intersect. As I zoom in or out, the distortions seem to undulate down the intersections. I assume there is some common mistake I'm making as I see these in models I didnt' create whether they use only triangles or larger polygons. I've searched but can't find anything as I don't even know what this problem is called. Here's an image showing some large distortions where 2 faces intersect as the model is moved down the z axis. http://atlbiz.com/images/1.jpg These 2 images show a slightly less serious distortion along a few seams as a different model is at different distances. http://atlbiz.com/images/2.jpg http://atlbiz.com/images/3.jpg Here's my initialization code: glShadeModel(GL_SMOOTH); glEnable(GL_DEPTH_TEST); glEnable(GL_LIGHTING); glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseLight); glLightfv(GL_LIGHT0, GL_SPECULAR, specularLight); glLightfv(GL_LIGHT0, GL_POSITION, LightPosition); glEnable(GL_LIGHT0); glEnable(GL_COLOR_MATERIAL); glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE); glMaterialfv(GL_FRONT, GL_SPECULAR, specularLight); glMateriali(GL_FRONT, GL_SHININESS, 128); This is my rendering code for a model consisting of only triangles: glClearColor(0.0f, 0.3f, 0.0f, 0.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity (); glTranslatef (0.0, 0.0, zoom); glRotatef(-xRotation,0.0,1.0,0.0); glRotatef(-yRotation,1.0,0.0,0.0); for(x=0;x<(int)xb1->fcount;x++) { glBegin(GL_TRIANGLES); glNormal3f(); glVertex3f(); glNormal3f(); glVertex3f(); glNormal3f(); glVertex3f(); glEnd(); } Thanks for any input.

Share this post


Link to post
Share on other sites
Advertisement
The first image (if I am interpreting it correctly) makes me believe that the issue could be a depth buffer issue. If the distances involved with these faces are large (i.e. 1 face spans -10000.0f to 10000.0f) you will get this because the depth buffer will not be big enough to contain all the data. To solve this, make the buffer bigger (if you can), or scale things down.


This can also happen if you are dealing with disances too small...In this case, scale things up.

For more info, google "z fighting."
EDIT: Also, if faces are too close together, this can happen. I don't think this is the case here, from what I can tell.

Share this post


Link to post
Share on other sites
Thanks for the tip. I tried scaling it down and that made it a lot better. The vertices were in the range of 1.0 to 35.0 so I scaled them with glScalef (0.01, 0.01, 0.01) and it looked much better.

Is there any general range of vertex values that you're best to stay within?

Thanks again.
RA

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!