Wierd Graphic Artifact

Started by
4 comments, last by jollyjeffers 18 years, 10 months ago
Ok, I'm very new to DirectX graphics in general. I'm still working on my .NET skills so instead of jumping into two languages at once, I'm using VB6 with DX8. I can write and understand C++ so if you have code examples for that, feel free to include them. Ok... the problem I am seeing is pretty simple to explain... I have a 3D terrain generated from a heightmap. I am currently only using brute force to do my work... every height has its own vertex... so on and so forth. I added a water quad that stays with the camera at a certain height and is always rendered (even if it cannot be seen anywhere in the scene. While scrolling across the terrain, I noticed that the water seems to have this strange artifact to it... A Hill comes out of the water and the water appears to move. It doesn't render consistently each frame that the camera is scrolling. I noticed that if I zoom in to the terrain very very very closely, that the artifact reduces itself down to very tiny triangles until at some point, the water appears correctly (but I am practically JUST above the water). Why is this happening? How do I fix it (ROAM?)? Thanks, -Matt (edited because I couldn't type worth anything)
Enoch DagorLead DeveloperDark Sky EntertainmentBeyond Protocol
Advertisement
That's called z-fighting. Try turning the near plane distance up when you calculate your projection matrix.
Jiia, you're my hero. Thank you very much. :)
Enoch DagorLead DeveloperDark Sky EntertainmentBeyond Protocol
I think it has to do with the distance in between the near and far clipping planes, so you don't have to change the near plane if you make the far plane shorter, get a nice balance.
Quote:Original post by Anonymous Poster
I think it has to do with the distance in between the near and far clipping planes, so you don't have to change the near plane if you make the far plane shorter, get a nice balance.

It's not the distance, but it is the ratio. Consider near/far plane values of 5/5000. You will get more than twice the improvement in accuracy by turning the near plane up 1 point than you would turning the far plane down 100 points.

The far plane is very flexible. It's the near plane that bites you. The closer the z buffer is to the screen, the more resolution it eats up. Turn your near plane up as far as you can manage it. Your far plane will make little difference as long as it's not at insane levels.
I believe a compulsory link/reference is required here: Learning To Love Your Z-Buffer [grin]

It's a very useful webpage if you're trying to get a grip on the mathematics behind how the depth calculations work. You can quite easily verify what Jiia is saying about tweaking the values by trying it on the above page...

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

This topic is closed to new replies.

Advertisement