0
\$\begingroup\$

I am learning DirectX 9 and I have these test models in my scene and this weird texture flashing happens.

If you look at the bottom of the picture you will see a blue area, that is supposed to be filled with the ground texture I have. So every time I move my camera the ground texture flashes very quickly and parts of it disappear lots of times a second. I know it's not a problem with my video card. What could cause this?

enter image description here

\$\endgroup\$
1
\$\begingroup\$

Your problem has nothing to do with texturing. Your are experiencing the ancient problem of Z-Fighting.

This should be caused either by some interpenetrations between your meshes or, less likely, due to very low accuracy of the Z-buffer in your graphics card.

\$\endgroup\$
6
  • \$\begingroup\$ Mesh interpenetrations are probobly the cause but what are they exactly and do I solve it by recreating the mesh or what do I do? \$\endgroup\$
    – MisterArch
    May 6 '14 at 22:35
  • 1
    \$\begingroup\$ @MisterArch: You probably have the range between zNear and zFar too great. You have to realize that the depth buffer is (usually) fixed-point, if you have a 16-bit depth buffer you have 65536 unique depths you can distinguish. Now if you have a near plane of 0.001 and a far plane of 10000.0, the smallest difference in depth you can distinguish is ~0.153 units (9999.999 <-- (zFar - zNear) / 65536.0 <-- (fixed-point resolution)). The solution is either to reduce the range between zNear and zFar or increase the precision of the depth buffer. \$\endgroup\$ May 6 '14 at 22:47
  • \$\begingroup\$ Where can i set the znear and zfar? \$\endgroup\$
    – MisterArch
    May 6 '14 at 22:57
  • \$\begingroup\$ @MisterArch: In your projection matrix. \$\endgroup\$ May 6 '14 at 23:00
  • \$\begingroup\$ Thank you very much that fixed it. This makes more sense now. When I was creating the projection matrix I made an error and put a 1.0 in the ZFar. \$\endgroup\$
    – MisterArch
    May 6 '14 at 23:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.