problem with perspective view


I am working on a simple visualization of terrain for use with flight simulator. There, terrain and runways are rendered. I have the following problem:
When rolling on the runway the runway and all of its components are not steady displayed, they are very jumpy. When I hold still they are displayed steady. The same applies for the wireframe model of the terrain. To better understand here is pic (the red arrow indicates the motion):

Has anyone a hint?

The numbers you use in the modelview and terrain transformations are too large and you are seeing vertex jitter due to floating point precision issues.

There is a fix, you need to perform your flight sim calculations in double precision float (64 bit), then take the eye position in double precision and subtract a large constant number from the translation component, then you can cast to 32 bit float and use the values for your viewing matrix (viewing will be (-x, -y, -z)).

You then take the same large value and subtract it from a double precision matrix translation above your terrain segments before placing the resulting translation into a single precision model matrix (model will be (-x, -y, -z)). Note that terrain section vertices should be relative to a local origin.

Now that large constant that you subtracted earlier will need to vary over time depending on where the eye is. You typically want some modulo effect where the number never exceeds an nice high precision single point falue.

If you have a space sim you’d subtract x,y,z but in the case of a flight sim you probably only need to subtract in x and y axes I think.

p.s. moving this question to the advanced forum.