Scene "flickers" when moving camera

Started by
4 comments, last by Erik Rufelt 14 years, 5 months ago
I'm a bit clueless as to what is causing this, so I'm not really sure what code to post. Basically, using C++ directx 9 I am creating some random building meshes and assigning random textures to them (which have been created using D3DXCreateTexture). When I am flying along the building geometry and textures seem to sort of flicker a pixel at a time back and forth (more so when textures are steeper angled away from the camera). Initially i thought it was to do with D3DXCreateTexture, but when I just make all the buildings untextured their geometry still has this flicker effect. Has anybody got any idea where I should be looking in my code? Photobucket I've circled in red the areas of buildings that flicker the most - when the camera is stationary it looks fine. thanks for any help
Advertisement
Sounds like a depth buffer issue to me. What are your near and far clip planes set to (In your projection matrix), and what is your depth buffer precision?

For D3DFMT_D16, you really don't want a near clip closer than 1.0f, and a far clip further than say 1000.0f or so.
For D3DFMT_D24S8 or D3DFMT_D24X8, you don't want a near clip closer than 0.1f, and a far clip further than 5000.0f or so.
(Random values picked out of my head). The main thing is that the near clip should be as far as possible, and the far clip should be as close as possible.
I am using D3DFMT_D24S8 and my near far planes are 1,1000. Another thing I am noticing is that increasing the resolution lessens the flickering a bit. I think this could be something pretty fundamental that I don't understand.
hm, spent almost all day looking at this and no luck. any other thoughts?
It really sounds as though you're using textures without mip-mapping, but if it happens when drawing without any textures then it can't be that.. It's hard to know exactly what you mean with flickering, and hard to see anything in your image. Does geometry from behind shine through?
It might be that you have T-junctions in your geometry. If you have a triangle with an edge between two vertices, and then other triangles share this same edge, but have extra vertices along the edge, then this can happen. You solve it by having each triangle share each of its edges exactly aligned with exactly one other triangle.
YOu can also try enabling anti-aliasing to reduce edge-flickering.
Here's an image of what I mean with the t-junction:


BTW nice city =)

This topic is closed to new replies.

Advertisement