3
$\begingroup$

I want to mark the intersection of lines with a spherical node with the following simple code:

Graphics3D[{  Black, Thick, 
Line[{{-1, 0, 0}, {1, 0, 0}}], 
Line[{{0, -1, 0}, {0, 1, 0}}], 
Line[{{0, 0, -1}, {0, 0, 1}}],  
{Red, Sphere[{0, 0, 0}, 0.1] }}]

In the Mac version of Mathematica 12, the plot displays correctly (the first figure), namely the crossing point of the lines is obscured inside the sphere. However, in the Windows version of Mathematica 12, the lines appear as in front of the sphere, as shown in the second figure, consequently, the crossing point of the lines inside the sphere is wrongly exposed. If I export the image in PNG or JPG format, the problem also exists in the obtained image file.

Is it a bug of the Windows version of Mathematica 12? Can it be solved?

Note: The problem is not caused by the setting of Opacity. In the Windows version, the sphere is totally opaque (Opacity=1).

Plot in Mac version:

enter image description here

Plot in Windows version:

enter image description here

$\endgroup$
3
  • 2
    $\begingroup$ This is z-fighting I think $\endgroup$ Jun 18 '20 at 13:31
  • 6
    $\begingroup$ Try switching to a different rendering engine on Windows like "OpenGL" or "Mesa" with: RenderingOptions -> {"3DRenderingEngine" -> "Mesa"}, or try changing the depth sorting to use BSPTrees instead of z-buffering: RenderingOptions -> {"3DRenderingMethod" -> "BSPTree"} $\endgroup$
    – flinty
    Jun 18 '20 at 13:48
  • $\begingroup$ @flinty Many thanks. The problem is solved by changing 3DRenderingMethod to BSPTree. $\endgroup$
    – zrysky
    Jun 18 '20 at 14:28
1
$\begingroup$

The answer was given in a comment:

@flinty Many thanks. The problem is solved by changing 3DRenderingMethod to BSPTree. – zrysky Jun 18 '20 at 14:28

$\endgroup$
0
$\begingroup$

I get

Graphics3D[{{Black, Thick, Line[{{-1, 0, 0}, {1, 0, 0}}], 
   Line[{{0, -1, 0}, {0, 1, 0}}], 
   Line[{{0, 0, -1}, {0, 0, 1}}]}, {Red, Sphere[{0, 0, 0}, 0.1]}}]

output

Graphics3D[{{Black, Thick, Line[{{-1, 0, 0}, {1, 0, 0}}], 
   Line[{{0, -1, 0}, {0, 1, 0}}], 
   Line[{{0, 0, -1}, {0, 0, 1}}]}, {Opacity[0.5], Red, 
   Sphere[{0, 0, 0}, 0.1]}}]

output

It is the built-in Opacity that makes the difference not the OS. My pictures are all done on MacOSx with Mathematica 12.0. It is possible to add Opacity to $DisplayFunction and have this automatic. So check for $DisplayFunction. Or just always add Opacity to the graphics directives.

Mind the extra curly brackets!

$\endgroup$
1
  • 4
    $\begingroup$ I'm pretty sure the problem is not caused by the setting of Opacity. In the Windows version, the sphere is totally opaque (Opacity=1). $\endgroup$
    – zrysky
    Jun 18 '20 at 11:06

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.