10
$\begingroup$

Consider this code

$data = With[{step = .1, r = 2}, 
   Table[Exp[-Norm[{x, y, z}]^2], {x, -r, r, step}, {y, -r, r, 
     step}, {z, -r, r, step}]];

Graphics3D[{Raster3D[$data, {{0, 0, 0}, {1, 1, 1}}, 
   ColorFunction -> (Opacity[#, Red] &)], 
  Raster3D[$data, {{1, 1, 1}, {2, 2, 2}}, 
   ColorFunction -> (Opacity[#, Red] &)]}]

The generated figure looks like

Obviously the transparency works within one Raster3D object but not between them.

  1. Is this an expected behaviour?
  2. How could I go around this, assuming I cannot generate everything in one Raster3D object? I want to be able to patch various Raster3D objects according to my liking.
$\endgroup$
10
$\begingroup$

Changing the rendering engine to BSPTree seems to help for me:

SetOptions[$FrontEnd, RenderingOptions -> {"Graphics3DRenderingEngine" -> "BSPTree"}]

enter image description here

Not sure if this is the best solution, but do try it out.

$\endgroup$
  • $\begingroup$ works perfectly, thanks $\endgroup$ – jhrmnn Jul 17 '15 at 21:59
  • $\begingroup$ I think this is because with the "^2" the values on the edge of the bounding box are still not zero, especially in the cube face centers. Try it with e.g. Exp[-Norm[{x, y, z}]^3.0] (which makes the spheres not touch the boundary). $\endgroup$ – Arnoud Buzing Jul 17 '15 at 22:03
  • $\begingroup$ I've realized that before and deleted my comment, probably while you were writing the reply, sorry about that $\endgroup$ – jhrmnn Jul 17 '15 at 22:09
  • $\begingroup$ @ArnoudBuzing Could you comment about this option? When should/could be tried? $\endgroup$ – Dr. belisarius Jul 17 '15 at 23:26
  • 1
    $\begingroup$ Note that Style[graphics, RenderingOptions -> {"Graphics3DRenderingEngine" -> "BSPTree"}] also works without making a persistent change to the $FrontEnd. (I assume SetOptions[$FrontEndSession, RenderingOptions -> {"Graphics3DRenderingEngine" -> "BSPTree"}] would work, too.) $\endgroup$ – Michael E2 Jul 18 '15 at 2:41

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.