Shaking Vertices
Hello all
Im trying to render a simple quad and any time the camera translates/rotates a small amount (doesn't happen with large transformations, tho it just might not be as noticable while moving) the vertices will shake. Iv noticed the problem get worse and worse as the vertices get further away from the origin. With vertices at 50,50,50 the shaking is almost unnoticable, at 500,500,500 its very bad, and much larger than that its unbearable. The vertices shake back and forth in the direction (position-origin). Each vertex seems to shake at its own pace, since the two triangles of the quad seperate/overlap slightly during the shaking.
Also, if the camera's look is somewhat parallel to the quad's normal and near it some odd visual effects occure. Parts of the quad will dissapear, or move, or warp.
I seriously doubt this is a problem with my transformation code (which I have spent hours looking over). Seems more like a Z-buffer (changing Z-buffer format did nothing) or floating-point precision issue. The problem occures at much smaller vertex positions on my laptop (crappy graphics card) than on my PC (6800 ultra).... :(
EDIT: This is definetly a DX problem, I altered the shader from the BasicHLSL DX SDK example to move the vertices far away, same shaking happens.
EDIT2: Seems this problem only occures when a triangle's vertices are far apart.Placing a smaller triangle extremely far away from origin didnt cause any problems.
Thanks in advance!
[Edited by - SteaIth on January 4, 2005 6:51:15 AM]
A few collected thoughts...
What sort of values are you putting into your projection matrix?
- Large zFar values and/or close zNear values can give bad results
What depth buffer format are you using?
- you'll get more errors on a Z16 buffer, and maybe if you use W-Buffers
What sort of display resolution are you using?
- I've seen "shaking" at very low resolutions (640x480 or less) when the rasterized coordinates are very close to a pixel boundaries.
Are you using any ZBias'ing?
- D3DRS_ZBIAS or D3DRS_SLOPEDSCALEDBIAS (iirc) can affect the final computation
Any clever transforms beyond the traditional scale/rotate/translate?
Are you manually altering the verticies or getting the D3D pipeline to do it?
- If you manually alter your vertex data, over a number of frames you can hit precision errors in the 'float' data that is rendered.
hth
Jack
What sort of values are you putting into your projection matrix?
- Large zFar values and/or close zNear values can give bad results
What depth buffer format are you using?
- you'll get more errors on a Z16 buffer, and maybe if you use W-Buffers
What sort of display resolution are you using?
- I've seen "shaking" at very low resolutions (640x480 or less) when the rasterized coordinates are very close to a pixel boundaries.
Are you using any ZBias'ing?
- D3DRS_ZBIAS or D3DRS_SLOPEDSCALEDBIAS (iirc) can affect the final computation
Any clever transforms beyond the traditional scale/rotate/translate?
Are you manually altering the verticies or getting the D3D pipeline to do it?
- If you manually alter your vertex data, over a number of frames you can hit precision errors in the 'float' data that is rendered.
hth
Jack
Thanks for the reply!
What sort of values are you putting into your projection matrix?
Nothing unusual here, near clip is at 1 & far at 1000
What depth buffer format are you using?
32 bit Z-buffer
What sort of display resolution are you using?
Problem is resolution independent, same at 640x480 as 1600x1200
Are you using any ZBias'ing?
No
Any clever transforms beyond the traditional scale/rotate/translate?
Nope, simple rotation & translation
Are you manually altering the verticies or getting the D3D pipeline to do it?
Vertices are in a static vertex buffer, their positions are never altered. In my vertex shader their positions are not changed (except for world-view-projection transform, of course)
What sort of values are you putting into your projection matrix?
Nothing unusual here, near clip is at 1 & far at 1000
What depth buffer format are you using?
32 bit Z-buffer
What sort of display resolution are you using?
Problem is resolution independent, same at 640x480 as 1600x1200
Are you using any ZBias'ing?
No
Any clever transforms beyond the traditional scale/rotate/translate?
Nope, simple rotation & translation
Are you manually altering the verticies or getting the D3D pipeline to do it?
Vertices are in a static vertex buffer, their positions are never altered. In my vertex shader their positions are not changed (except for world-view-projection transform, of course)
Does the problem also occur using a 16 bit depth buffer? Also, did you download the latest video drivers?
You could also try using the reference rasterizer just to ensure it's not something to do with rasterization, rather than transformation.
Does the problem also occur using a 16 bit depth buffer? Also, did you download the latest video drivers?
Yes, 16 bit depth buffer exhibits the same problem. Video drivers are up to date.
You could also try using the reference rasterizer just to ensure it's not something to do with rasterization, rather than transformation.
I tried using the reference rasterizer & software vertex processing, neither helped.
Yes, 16 bit depth buffer exhibits the same problem. Video drivers are up to date.
You could also try using the reference rasterizer just to ensure it's not something to do with rasterization, rather than transformation.
I tried using the reference rasterizer & software vertex processing, neither helped.
Quote:Original post by SteaIth
EDIT2: Seems this problem only occures when a triangle's vertices are far apart.Placing a smaller triangle extremely far away from origin didnt cause any problems.
Sounds like you're bumping into the limited precision of floating-point values somewhere in the pipeline, most likely in the calculation of the interpolator gradients.
A similar problem can occur with texture coordinates. Suppose one corner of a quad is (10000, 10000) and the opposite is (10001, 10001). With wrapping on this should, in principle, be no different than (0, 0)-(1, 1), but because of the way floating-point works, it can cause problems like texture shaking and funky artifacts in the filtering on some hardware.
The 6800 would have higher precision than older hardware, which explains why higher values are needed before precision artifacts start surfacing.
The simplest solution for your case would probably be just to tesselate the large quad into a bunch of smaller quads. This will help the intermediate values -- in particular the subtractions of vertex coordinates -- to maintain their precision.
I'd be curious if this happens if the quad is simply flat shaded with no textures applied. That is, I'd like to know if the problem is simply a shifting of the vertices, or if it's due to a problem with the interpolants in the rasterizer as Donavan suggests.
Yeah, giving it a little more thought I'd guess it's more likely happening in the clipping. The jittering only happens with a large quad which is what makes me think that it's a subtraction between the vertex positions -- the large resulting value is crowding the precision out of the mantissa.
Sorry this may be a little late, but have you checked your camera code, specifically position & lookat vectors.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement