Aleksey Shubin
Aleksey Shubin

Reputation: 1998

WPF 3D textures intersection

I'm using Helix 3D Toolkit to draw 3D objects in WPF application. Currently I'm working on drawing 2D shapes in 3D (rectangles) and having a problem with textures when the shapes intersects:

Intersecting shapes texture problem

The intersection changes when moving the camera:

Intersecting shapes texture changes

I tried to place one shape a bit higher then the other one (Z = 0.101 and 0.102), but the result is the same. If I increase the difference (Z = 1 and 2), the problem is solved. But that's too high, because there will be other 3D objects on top of the shapes and the shapes should not be overlap them.

Why this happens? I thought that even a small difference in height should be enough to clearly identify which texture should be displayed.

I tried to google, but I even don't know how to describe this problem correctly to get relevant results.

Upvotes: 1

Views: 690

Answers (1)

L Chougrani
L Chougrani

Reputation: 726

This is a problem called Z-Fighting, pretty common in 3D graphics. if you have access to the shader (either HLSL or GLSL) or the GL/DX context, you could resolve it from there.. If you don't then, possible solution could be either :

  • Move slightly one model in front of another (as suggested by pushpraj). you can reduce/increase the amount by which you move them by fiddling with your camera Near/Far plane distance.
  • Merge your 2 models into one and your two textures into one, and manage the texture coordinates.

Upvotes: 0

Related Questions