Flashing terrain (pic)

Started by
11 comments, last by Jackthemeangiant 22 years, 5 months ago
I finaly got lighting working in my terrain engine =) And now I have a few more things to fix with it before I start to texture it. The polygons from behind the ones that are closer to the camera are flashing through as you can sorta see in the pic. How can I fix this problem?
Advertisement
are you using OpenGL lights? ''cos it seems to me like the normals aren''t calculated correctly. If you are using glColor() to set the light at each vertex, then the problem is somewhere else.
Yes, I am using Gl_lights, and I have been through this already, and I am 99% sure the normals are correct....


It may be a problem related to the depth buffer... a z-fighting scenario if you will.

Are you using a 32-bit depth buffer? This will help add more precision. Also, try to move your far clip plane in, and your near clip plane out a bit, as this will also help with precision.

Another thing... have you enabled back-face culling ( glEnable(CULL_FACE) ) ? Thats always good to have on (as long as aren''t drawing an object that is translucent/transparent)
hi there!
(For Jack)
Jack I think there is still something wrong with the normals sorry but it seems like that.
one more thing tell me
Did you implemented something to fly (or move)through the terrain? if so then tell me what happens to the terrain as you move (forward/backward or up/down ..).

(For Monkey)
Hi sorry i did not get your point on using a 32-bit depth buffer. Please explain it further.Waiting for your response.

Good luck Jack you are going really fine .


manni
manni
I had the problem of my terrain flashing and flickering, and it was a z-fighting problem. Make sure in your gluPerspective function you set the near plane to greater than or equal to 1.
If at first you don't succeed, redefine success.
Thanks guys, I set the near plane to 1.0f, and no more flickering =)

Do my normals still look incorrect?....I have never seen an untextured terrain engine with gl_lighting, so I have nothing to reference it to.

Here is another picture with out the flashing:

http://jackthemeangiant.l33t.ca/terrain2.jpg

If my grid looks like this:



When I calculate the vertex normal, should I calculate the normal for the 6 surounding triangles, then average them, or calculate normals for the 4 surounding quads?
The point of a vertex normal is to show the curved surface. So your best bet is to use your terrain function itself to generate your vertex normal.
quote:Original post by feagle814
...So your best bet is to use your terrain function itself to generate your vertex normal.



What do you mean by your your terrain function ?
Just replying to manni...

When you choose your pixel format (or whatever it may be called on non-Wondoze systems), you supply numbers for your desired colour depth and depth-buffer precision (among other things)... you can set this to 16 bits for speed and memory saving, but a 32 bit buffer will give much better accuracy, thus reducing z-fighting.

As a side note for everyone else... its worth remembering that pushing your near clip plane out will make more difference than moving your far clip plane in (due to the way z-values are more accurate/concentrated the closer you are to the front plane).

As for your normals Jack, it may not be a good idea to use the normals of the quads, as they may no always be planar (and therefore will not have a true normal). You can use the normals of all the triangles that use a vertex, and this should give ok results, but I think what feagle is getting at is that the normals should be calculated for the curved surface you are trying to simulate (rather than the polygon representation of it).

How are you generating your height-fields? If the points are generated by a mathematical equation (splines, curves, etc), then I assume you can use your knowledge of that to find normals. If you are using some other method (fractals, perlin noise, or scribbling ridges and valleys onto a bitmap image in Paint ), then I guess the best approach is to use the normals to the triangles..??

This topic is closed to new replies.

Advertisement