Does anybody know why this looks so screwy?

http://www.mycgiserver.com/~movegaga/screwy.jpg

…and hopefully, what to do about it?
(the strange, blocky edges)

You mean the blocky edges of the buildings? It looks like z-fighting to me (although strangely regular). Basically you’re lacking precision in your z-buffer.

You can switch from a 16bit depth buffer to a 24 or 32bit one, which will give you more range. On the other hand, that won’t help people with voodoo cards etc. So what you need to do is reduce the distance between your near and far clipping planes. Since the z-buffer is logarithmic, most of the precision is used close to the camera - so first try pushing your near plane out a little. Often people will set this to something like 0.1 when 1 is much more useful and nigh-on identical (or worse, your near plane is at 0, but you’d probably have seen weird happenings before now already).

The near plane can probably be set much higher than that even - 100 or more. And the far plane can be much closer too - 20000, 30000 perhaps? And stick a little fog in as well to prevent buildings from popping into existence.

And bloody mouse control!!! I HATE using the keyboard!

Cas :slight_smile:

Thanks, that was it :smiley:

My near plane was 0.1 and I put it at 1.
My far plane was at 2500 and I kept it there.

But erm, regarding fog, I thought about that but would I still be able to see the background?

Fog and skyboxes/skydomes etc. don’t tend to work well together :frowning: On the other hand, since you’ve got a pretty fixed view you can make use of that… You could add a black skyline to the background image slightly above where the buildings pop-up and put some black fog on the buildings. Or you could put some simple LOD in to reduce buildings to an untextured quad in the distance, and keep drawing them much further.

Theres a ‘proper’ way of doing good fog+sky, which is something like:

  • draw all landscape into just the depth buffer to get the visibility info.
  • Draw the background without any depth testing.
  • draw all the landscape again, but with the fog setup to affect the transparency instead of a colour.

This way, you get the landscape fading into view from out of the sky ;D Look really good and probably worth it in this case…

[quote]Theres a ‘proper’ way of doing good fog+sky, which is something like:

  • draw all landscape into just the depth buffer to get the visibility info.
  • Draw the background without any depth testing.
  • draw all the landscape again, but with the fog setup to affect the transparency instead of a colour.
    [/quote]
    What is the first render run good for? Where is that visibility evaluated?

For ‘normal’ fog you can

  • render the skybox/dome w/o writing z-buffer
  • render the fogged scene.

This way the skybox won’t be fogged out??

For Java3D btw, the Background node does a pretty good job for skybox rendering.

Unfortunartly, your method causes ugly poping of the landscape when it becomes visible for the first time - which kinda defeats the point of the fog in the first place :o

The first drawing pass is needed to get a perfect depth buffer for use when drawing the landscape for the second time. Because the landscape is drawn with transparency only the visible pixels should be drawn, this correctly fades everything into the background, and you dont get any popup :slight_smile:

Still hard to see, but I have an imagination…

If the scene itself contains transparent things, they still have to be sorted out an rendered regardless of the existing depth info I suppose?

For our case here, the fog itself prohibits anything from popping up into the scene. But it’S white, not alpha.

Hm, now I think of it I couldn’t get fog to write alpha values out. But yes, the way to do it is to actually have your background graphic fade at the bottom to the fog colour. In the terrain demo I had brown mountains on the horizon and my fog was brown, and that worked quite well, although the horizon was rarely visible.

Cas :slight_smile:

Yes, we have white fog and a skybox being white at the horizon.

So do you get any visual poping with skyscrapers etc., or is the landscape low enough to avoid that?

Ahhhhhhhhhhhh - now I begin to understand where the problem really is … a fog-colored object popping in against a dark sky or so…

Yes, I’m sure they would pop in. You’re right. Fortunately, no skyscrapers and our fog is >4km away :slight_smile:

You can see the effect e.g. in BF1942 with fog-colored planes in the skies…

But what about things floating in the sky? I don’t want them to be fogged. Would look awful I suppose against a clear background.
Maybe height fogged so that only the surface is fogged?

(BTW that low 41fps in the screenshot (it actually got even lower sometimes) is fixed by a quick sort. Just so that you know ;). Don’t you just hate low framerates? ;D)