6
$\begingroup$

I make my graphics in Mathematica using the Wolfram Language. This works quite well, but I have run into an issue that will make it work much nicer if it is solved.

In the following code, I render a Cuboid and then place a few Graphics3D primitives around it. It becomes readily obvious that the concentrated region of intersecting graphics have issues with their order of rendering.

Graphics3D[{{Yellow, Opacity[0.25], 
   Cuboid[{-4, -1.7, -1}, {4, 1.7, 0.}]},


  {Dashed, Thickness[0.01], 
   Arrowheads[0.05, Appearance -> "Projected"], 
   Arrow[Line[{{0, 0, 0}, {5.4, 0, 0}}]], 
   Arrow[Line[{{0, 0, 0}, {0, 3.4, 0}}]], 
   Arrow[Line[{{0, 0, 0}, {0, 0, 2.5}}]]},

  {Black, Cuboid[{-3.4, -2.6, 0}, {-3.6, 2.6, 0}], 
   Cuboid[{3.4, -2.6, 0}, {3.6, 2.6, 0}]},

  {Thickness[0.0325], Green, Arrowheads[0.125], 
   Arrow[Tube[{{0, 0, 0}, {4.75, 0, 0}}, .1]]},

  {Thickness[0.02], Red, Arrowheads[0.09],
   Arrow[Tube[{{0, 0, 0}, 2.75 {1, 0, 0}}, 0.1]]}

  },

 Boxed -> False, ImageSize -> 1000, ViewAngle -> Automatic, 
 ViewCenter -> {0.5`, 0.5`, 0.5`}, ViewMatrix -> Automatic, 
 ViewPoint -> {1.3135668740464197`, -2.8819650173048537`, 
   1.1911421856516324`}, ViewProjection -> Automatic, 
 ViewRange -> All, ViewVector -> Automatic, 
 ViewVertical -> {0.07086652061143876`, -0.17857804014486425`, 
   0.9813703785189605`}]

Simple Rendering Order Graphic

How can I control the order of rendering?

The goal is to deliberately prevent or encourage the overlap of parts of Graphics3D creations.

$\endgroup$
  • $\begingroup$ Are you looking to hide the dashed line behind the tubes, or have it completely in front? $\endgroup$ – Chip Hurst Feb 23 at 0:43
  • $\begingroup$ @ChipHurst well, I was interested in controlling it in a general sense. But, specifically, I'd like the dashed line behind the tubes, and the red tube rendered on top of the green tube. Maybe other issues will pop up after that, but it seems to me that the tube portion of the arrows are having issues with which one should render on top of the other. I'd like to control that. $\endgroup$ – CA Trevillian Feb 23 at 0:49
7
$\begingroup$

We can address the z-fighting and line depth issue with a Method option. Unfortunately there's still some z-fighting between the tubes, so we can just perturb the green radius near the origin.

Graphics3D[{{Yellow, Opacity[0.25], 
   Cuboid[{-4, -1.7, -1}, {4, 1.7, 0.}]},


  {Dashed, Thickness[0.01], 
   Arrowheads[0.05, Appearance -> "Projected"], 
   Arrow[Line[{{0, 0, 0}, {5.4, 0, 0}}]], 
   Arrow[Line[{{0, 0, 0}, {0, 3.4, 0}}]], 
   Arrow[Line[{{0, 0, 0}, {0, 0, 2.5}}]]},

  {Black, Cuboid[{-3.4, -2.6, 0}, {-3.6, 2.6, 0}], 
   Cuboid[{3.4, -2.6, 0}, {3.6, 2.6, 0}]},

  {Thickness[0.0325], Green, Arrowheads[0.125], 
   Arrow[Tube[{{0, 0, 0}, {4.75, 0, 0}}, {0.0999, .1}]]},

  {Thickness[0.02], Red, Arrowheads[0.09],
   Arrow[Tube[{{0, 0, 0}, 2.75 {1, 0, 0}}, 0.1]]}

  },

 Boxed -> False, ImageSize -> 1000, ViewAngle -> Automatic, 
 ViewCenter -> {0.5`, 0.5`, 0.5`}, ViewMatrix -> Automatic, 
 ViewPoint -> {1.3135668740464197`, -2.8819650173048537`, 
   1.1911421856516324`}, ViewProjection -> Automatic, 
 ViewRange -> All, ViewVector -> Automatic, 
 ViewVertical -> {0.07086652061143876`, -0.17857804014486425`, 0.9813703785189605`},
 Method -> {"RelieveDPZFighting" -> True, "EdgeDepthOffset" -> False}]

enter image description here

|improve this answer|||||
$\endgroup$
  • $\begingroup$ Absolutely fantastic. Exactly what I could not understand how to do!! Thank you, Chip. $\endgroup$ – CA Trevillian Feb 23 at 0:57
  • $\begingroup$ Say, Chip, is there a method one can set such that the dominance of text inserts are avoided? I would think since they're placed into the 3D space, that they would not overlap the other 3D graphics within the same space when they are behind them, but this is not so. Overall, it applies to the origin of my question as to how exactly one can control or dictate the order of 3D graphics rendering. $\endgroup$ – CA Trevillian Feb 24 at 23:08

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.