Surface display screwed up during zooming

Hi, I have a strange problem regarding surface displaying under lighting. I draw a foot surface, and add lighting. Suppose I am looking at the back side of the foot. Initially it looks fine. However, when I start zooming by moving my camera(using gluLookAt()) closer or farther from the original camera position, the foot’s back surface starts looking funcky. Sometimes I can see the front side of the foot surface although I am stricly looking at the back of the foot. In general, the surface looks fine in some camera positions and looks funky in other camera positions. One major problem is that I often see the opposite surface I have very little clue what could have gone wrong here. Can some experienced programmers point out possible causes?

Sounds like your near-plane is intersecting with the geometry? Not really an advanced topic, but try setting your near-plane to something closer (like 0.001f)

I have tried that but the problem still persists. I just found that the surface display would become funky during rotation as well. At some rotation angle, the surface looks fine, but at another angle, the “backside” surface would become the frontside surface.

I suppose you are using gluPerspective call… Could you post piece of your code with this call?

yooyo

Have you made sure to enable depth-test, back-face culling (with the same winding-orientation that you use to specify your triangle - typically counterclockwise).

:slight_smile: - also, a screenshot might be a good idea, “funky” just might not be descriptive enough :slight_smile:

\hornet

I am doing a marching cube data visulization project. Since the triangles of my surface do not always have the front face facing outside, I hope to avoid the curlling function. I do have the depth test enabled.

Here is two screen shots.

fine image, looking from behind the feet
funky image, still looking from behind the feet, but you can see the front of the toes appearing

As of lastest, I found that if I zoom in very close to the surface, and rotate it, there seems to be no problem. The problem arises when I am zooming away from the surface. Then it seems the depth testing fails, i.e. the “back surface” keeps popping to the front, like pic2 shows.

To get more depth buffer precision:

  • Use a larger near plane distance (important)
  • Use a smaller far plane distance
  • Use a higher precision format like 24 bit instead of 16 bit
  • Richard