2
$\begingroup$

What is the position of FaceGrids used in Graphics3D? The example below suggests it is at a depth around 2% of the plot box. Cuboid at 0.1 sits below the grid, cuboid at 0.3 sits above and the one at 0.2 blends with the grid partially. Interestingly, the cuboids at 0.1 or 0.2 are hovering above the grid plabe even though the grid is drawn over them. Can I fix this? Can I place the FaceGrids at the very edge of the plot, i.e. at 0? Version 14.1, MacOS

Graphics3D[
 {
  Cuboid[{3, 3, 0.1}, {7, 7, 0.1}],
  Cuboid[{3, 0.2, 3}, {7, 0.2, 7}],
  Cuboid[{0.3, 3, 3}, {0.3, 7, 7}],
  Sphere[{5, 5, 5}, 2]
  },
 Boxed -> False,
 PlotRange -> {{0, 10}, {0, 10}, {0, 10}},
 ViewPoint -> {1, 1, 1},
 Lighting -> "Neutral",
 FaceGrids -> 
  Table[{face, {Range[0, 10, 1], 
     Range[0, 10, 1]}}, {face, -IdentityMatrix[3]}]
]

Graphics3D image

$\endgroup$
6
  • $\begingroup$ I can't reproduce exactly what you have written. It seems to be Mathematica version dependent. I suggest to use 3 different sizes for the cuboid so that they are easily recognizable, for example Cuboid[{4, 4, 0.1}, {6, 6, 0.1}], Cuboid[{3, 0.2, 3}, {7, 0.2, 7}] , Cuboid[{0.3, 2, 2}, {0.3, 8, 8}] . I guess the problem is linked with the option PlotRangePadding, but I have no time to investigate further today. $\endgroup$
    – andre314
    Commented Sep 29 at 20:01
  • $\begingroup$ Indeed, it is version dependent. Prior to the upgrade from version 13, the grid lines were correctly not drawn over objects in front of the grid plane. PlotRangePadding -> 0 did not help. $\endgroup$
    – lixpas
    Commented Sep 30 at 10:07
  • $\begingroup$ This is reproducible in 14.1 on Windows. Rationalize changes nothing. $\endgroup$
    – user64494
    Commented Sep 30 at 19:31
  • 1
    $\begingroup$ To avoid blending with the grid, use Style[Graphics3D[...], RenderingOptions -> {"3DRenderingMethod" -> "BSPTree"}] or any other of the similar methods mentioned in RenderingOptions. $\endgroup$
    – Domen
    Commented Sep 30 at 19:38
  • $\begingroup$ @Domen Thank you, specifying RenderingOptions indeed solves the issue. I should have realized this is a problem of rendering. Would you like add this as an answer so I can accept it? $\endgroup$
    – lixpas
    Commented Sep 30 at 20:11

1 Answer 1

2
$\begingroup$

Oftentimes, weird overlapping artifacts in Graphics3D come from the Z-fighting. The first trick in the book is to change the "3DRenderingMethod" in RenderingOptions to one of the more accurate methods, such as "BSPTree":

Style[Graphics3D[...], RenderingOptions -> {"3DRenderingMethod" -> "BSPTree"}]

enter image description here

$\endgroup$
2
  • 1
    $\begingroup$ Why this does not work on cloud version? $\endgroup$ Commented Sep 30 at 20:59
  • $\begingroup$ @azerbajdzan, difficult to comment why, but note that rendering is done by the front-end, and especially in 3D graphics highly depends on the graphics hardware. I assume they decided it's not feasible for their Cloud servers to support this. Of course this is very clearly indicated in the documentation (top right). $\endgroup$
    – Domen
    Commented Sep 30 at 21:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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