Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Bug introduced in 7.0.1 or earlier -- persists through 10.0.1 or later

I have arranged a certain configuration of cubes in 3D using the following code:

   {Cuboid[{i, j - i + 1, j + 1}]},
   {i, 1, 4, 1}, {j, 1, 4, 1}], Lighting -> {{"Ambient", White}}, 
   Boxed -> False, ViewPoint -> {-1, -1, 1}]

Computing this as it is displays the following graphic: cube stack

This is fine, but the issue is what happens when you zoom in to this image in Mathematica. Doing so reveals extended edges in some of the corners shown here: enter image description here

I would like to know why this is happening, and what I need to do to get rid of the extended edges. Is this perhaps happening because Mathematica is not completely updating the graphics upon zooming?

share|improve this question
I see the same problem (ver. 8.0.4 OS X). After some experimentation I found that {Opacity[0.99], Table[{Cuboid[{i, j - i + 1, j + 1}]}, {i, 1, 4, 1}, {j, 1, 4, 1}]} is a workaround. –  Stephen Luttrell Dec 5 '12 at 0:31
@StephenLuttrell, with Opacity[0.99] I still see the problem 8.0.4 on Win7x64. –  s0rce Dec 5 '12 at 0:35
With Opacity[1] I see the problem on OS X, but Opacity[0.99] fixes it. –  Stephen Luttrell Dec 5 '12 at 0:37
Same on Linux, Opacity[0.99] fixes it. –  Andreas Lauschke Dec 5 '12 at 1:14
Linux and 8.0.4 64 bit , I still see the problem with Opacity[0.99]. –  image_doctor Dec 5 '12 at 12:51

1 Answer 1

up vote 15 down vote accepted

Unfortunately I haven't seen this question earlier so my two cent to this problem may be a bit late. Please take my words with the appropriate suspicion because I have no knowledge of the internal implementation. My explanations are purely based on observation and what I think happens here.

Let's first make clear that we all agree on what we are seeing. The little crosses are the back edges of the cubes which shouldn't be invisible because they are covered by the faces in the front. Although your example looks really awesome in its simplicity, let us create a better one: A square and triangle polygon folded together:

Mathematica graphics

Now we could rotate the graphics so that we don't see the triangle part any more and fold it closer and closer together

    {{0, 0, 0}, {1, 0, 0}, {1, 1, 0}, {0, 1, 0}},
    {{0, 0, 0}, {1, 1/2, d}, {0, 1, 0}}
    }], Boxed -> False, PlotRange -> {{0, 1}, {0, 1}, {0, 1}}],
 {d, 0, .5}]

Mathematica graphics

As you see, the edges which shouldn't be visible at all appear through the squared polygon. This should give us the important clue what happens here.

You might already know, that the image of the 3D scene you observe is a projection from the 3D scene onto your 2D screen plane. So all polygons (and other primitives) are transformed so that the pixels on your screen give you the impression you are looking at a 3D thing. One important step in this process is to decide whether or not a pixel is covered by another one, which is closer to the camera. This step is called hidden surface determination and is crucial to give a realistic graphic.

The problem with this is, that this algorithm should work very fast because otherwise all the nifty rotations/translations of 3D graphics wouldn't work. Therefore, this stuff should be done by your graphics card which works with finite precision.

This is the reason why we see the lines, because the determination of which object covers the other was not exact enough. Fortunately, Mathematica comes with several hidden surface determination algorithms and binary space partitioning is far more exact than the algorithms in your graphics card.

So if you go to Edit->Preferences and then select the Advanced to open the Option Inspector, you will find the appropriate entry under the Graphics Options

enter image description here

Select BSPTree and rotate your graphics to update it and you'll see that the additional lines disappear even if you go really close

Mathematica graphics

Before you open the champagne, be aware that this slows down the rendering dramatically. Just make some more cubes (for instance 100 in each direction) and try to rotate the graphics and then switch the method back to Automatic and you'll see the vast difference.

share|improve this answer
+1 very neat explanation! –  Leo Fang Jul 30 '13 at 4:31
I feel the edge problem with hardware acceleration leaves room for improvement. In some cases artifact edges are quite prominent even though the polygons are not that close... a lot of other 3D graphics software does much better here. –  Yves Klett Jul 30 '13 at 8:21

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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