Archived

This topic is now archived and is closed to further replies.

Flashing terrain (pic)

This topic is 5868 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 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?

Share this post


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

Share this post


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

Share this post


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

Share this post


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

Share this post


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

Share this post


Link to post
Share on other sites
Just a quickie ... what cards support 32 bit Z buffer? Because most only do 24 bits max - with the other 8 bits reserved for stencil ...

Share this post


Link to post
Share on other sites