What might cause these graphic glitches?

Started by
7 comments, last by Daniel E 14 years, 10 months ago
Hi, i've been trying to figure this out forever. The water and the terrain cause some weird graphic glitches. They become worse the greater the camera distance is. It looks ok when you're close though. I have tried all render states i could think might cause it but the problem always remains. I'm using the NVidia Ocean shader btw. Here are the screens. The second screen shows the close up view which looks ok: any help would be very appreciated
Advertisement
if it gets worse the further away the camera is, it looks like depth precision,

try increasing the value of your near plane (if its at 0.1 try changing to 1) because it looks like a lot of your precision in the depth buffer is being lost or used up close to the camera.

Alternatively if your using 16bit depth buffer try upping that to 24, but I think the near plane will sort you out best.
I don't know the shader, but it looks like you encouter a zbuffer and maybe a mipmapping problem.

Zbuffer problem:
Try to increase the zbuffer resolution (atleast 24 bits).

Mipmapping:
It seems that your normal map suffers from mipmapping/compression artifacts. Try to use an already compressed fileformat (dds/dxt5, normal.x=green,normal.y=alpha,normal.z=sqrt(1-dot(normal.xy,normal.xy))) to get better quality normals at lower mipmapping resolutions.

--
Ashaman
It seems like z-fighting to me. If you are using OpenGL, it has a method named as glPolygonOffset, which introduces a slope bias to the polygons in view space. I don't know exactly how it is used but it can be of help.
i'm using directX

increasing the near plane to 10.0f and greater creates less artifacts but they are still there when the camera is far away.

it's confusing because objects on the terrain look fine.

i'm using

d3dpp.EnableAutoDepthStencil = TRUE;
d3dpp.AutoDepthStencilFormat = D3DFMT_D16;

i don't know how to increase the depth buffer to 24 bit yet.

is it one of these formats?

D3DFMT_D24S8 = 75,
D3DFMT_D24X8 = 77,
D3DFMT_D24X4S4 = 79,
D3DFMT_D24FS8 = 83,

The normal Map on the water is a dds file that came with the nVidia shader.

i'm loading it like this D3DXCreateTextureFromFile(device, "textures/water/waves2.dds", &g_Texture1);

for the terrain normal map: D3DXComputeNormalMap(normalmap, heightmap, NULL, NULL, D3DX_CHANNEL_RED, 6.5f);

Changing the sampler states in the terrain shader and water shader didn't have an effect.

sampler TextureOne = sampler_state
{
MipFilter = LINEAR;
MinFilter = LINEAR;
MagFilter = LINEAR;
};

These are the states that are set in the ocean shader:

ZEnable = true;
ZWriteEnable = true;
ZFunc = LessEqual;
AlphaBlendEnable = true;
CullMode = ccw;
Hi,

Quote:i don't know how to increase the depth buffer to 24 bit yet.

is it one of these formats?

D3DFMT_D24S8 = 75,
D3DFMT_D24X8 = 77,
D3DFMT_D24X4S4 = 79,
D3DFMT_D24FS8 = 83,


All of these can be used; but you must select one.

If you're not using (and not going to use) stencil buffer, you can use D3DFMT_D24X8. Otherwise, depending on size of your stencil usage (4 bits or 8 bits), you must select one of the others.

Hope this helps.
There's no "hard", and "the impossible" takes just a little time.
1. 16-bit depth buffers are extremely low precision - there's only 65536 possible depth values.
2. Remember that something like 70% of the Z-buffer range is used in the first 30% of the scene. That means that objects further away will have more issues. You can use a W-buffer instead (SetRenderState(D3DRS_ZENABLE, D3DZB_USEW) or something) which will help mitigate these problems.
3. You want the distance between your near and far clip planes to be as small as possible. With a 16-bit Z-buffer, I wouldn't put the far clip plane any further than 1000 units, and the near clip should always be as far away as possible.
4. If you use a 32-bit or 24-bit Z buffer(D3DFMT_D32 or D3DFMT_D24X8 respectively), make sure you check that the graphics card can handle it (With a call to IDirect3D9::CheckDeviceFormat to see if that format is supported, and then a call to IDirect3D9::CheckDepthStencilMatch to see if it can be used with the backbuffer (Older NVidia cards require that the Z-buffer is the same bit depth as the backbuffer). I've covered this stuff in a tutorial I wrote.
I tried using D3DFMT_D24X8.

Wow.. it works!

Thank you so much!!!

I wonder how this affects the performance? I couldn't notice an impact.





I want to upload some source codes for the community soon because i've got 99% of my knowledge from this website :)
@Evil Steve

thank you for the informations. I will try the optimizations you suggested.

i definately want to make sure it works on older hardware because it must work on old university computers :)


My far clip plane is at 4000.0f right now. When i set it to lower values, the water gets clipped too early :/

Could the scale of my world be just too large? I adjusted everything to the subjective feel of the camera. When i change the scale of my world, the camera speed and rotation feels off. I'm using a generic camera class from a book. Could the camera be the reason for the far clip plane feeling to near?

This topic is closed to new replies.

Advertisement