# Rendering Raster3D intersecting with vector primitives

Bug introduced in 9.0 and persists through 11.1.1
Reported to WRI under [CASE:3678032]
It crashes the FrontEnd of Mathematica 10.4.1 on Windows

UPDATE #2 27.04.17 Redacted due to outdated GPU driver on my machine

UPDATE 27.04.17
WRI followed up; the issue is not resolved in 11.1.0, but they "see much improved behavior in 11.1.1". Can anybody check this one?
UPDATE 25.04.17
I received an e-mail from WRI, they believe the issue has been resolved in 11.1. Can anybody verify this?

Consider this simple code:

i3d = 1/4 RandomReal[1, {5, 5, 5}] // Image3D


Now Show me this:

Show[{i3d, Graphics3D[{FaceForm[Opacity[.6]], Cuboid[{3, 3, 3}]}]}]


It takes a lot of time to render and repeatedly freezes and unfreezes MMA.

Note that simply i3d returns a very responsive object, renders fast, etc.

I could live with the above. However I need to generate a high-resolution image, like so:

Show[{i3d, Graphics3D[{FaceForm[Opacity[.6]], Cuboid[{3, 3, 3}]}]}, ImageSize -> {2400, 1600}]


But when I run this line of code, MMA returns an empty box with a tiny little square of the color of i3d in the top left corner of the output cell.

I am using version 10.2 on Win7x64 professional. I have 8GB of RAM (I noticed, that MMA consumes several GB when running the first Show statement).

Is this a bug? Has it been fixed in a later version?

My eventual desire is to get a hi-res of the following figure:

The blue cloud is made up of an array of voxels. The yellow triangles in the top half of the image have a setting like Specularity[White, 10], Opacity[.6]. When I try to create this figure with Show[{...}, ImageSize->{900,600}], it takes quite a while, but eventually returns a result. When I crank up the ImageSize I get a problem similar to the MWE above. When I exclude either the cloud or the yellow triangles, everything works fine again.

The problems appear to have become worse through progressive versions of Mathematica.

V10.0 (Linux): My colleague managed to generate hi-res images with desired results on our institute's high-performance cluster, although rendering took an abnormally long time.

V10.1 and V10.2, (Win7x64 professional): Rendering fails for combinations of Raster3D, Opacity, and a Polygon or Cuboid at high resolution, but takes a long time, yet gives a correct result for lower resolutions (ImageSizes). For a higher resolution on 10.2 the output cell is generated immediately, but is incorrect:

Note the few pixels in the top-left of the output cell, which are of the color of the Raster3D.

V10.4: According to AlexeyPopkov (link), combining Raster3D and Point without any mention of Opacity now crashes the front-end. This is a different, but seemingly related problem. It does not occur in 10.1 and 10.2. Attempting to render my image in 10.4 on the institute's cluster quickly consumed 0.1 TB of memory without results and froze the front end. At this point we killed the process, but, presumably, it would have led to a crash of the front end.

• Doesn't Raster3D[] work? – J. M. is away Jul 29 '16 at 12:52
• @J.M. For my bigger problem I have used various combinations of Image3D and/or Show/Graphics3D@*Raster3D etc, etc. In the end Show always gives a Graphics3D[{Raster3D[...], Opacity[.6], Cuboid[...]}] or similar. If you have a concrete working example, please do share. A colleague managed to generate the image on our institute's grid with MMA 10.1. Contrary to this, MMA 10.4 consumed 0.1 TB of memory on the MWE, before we killed the process. – LLlAMnYP Jul 29 '16 at 13:25
• I also had a problem rendering Raster3D intersecting with Point using Mathematica 10.4.1 for this answer (the bottom image): it simply crashed the FrontEnd and I was forced to use version 10.0.1 which works fine. Your example also crashes my FrontEnd. Since you can't render also with versions 10.2 and 10.4, I assume the bug was introduced in version 10.2 and become even worse in the latest release. I have added the appropriate tags and the header. – Alexey Popkov Aug 1 '16 at 5:39
• @AlexeyPopkov I can render a Point inside a Raster3D just fine on MMA 10.2. As I can also render a cuboid. The problem arises when I introduce Opacity[.6], and it also happens in 10.1. I think your edit is somewhat inaccurate. – LLlAMnYP Aug 1 '16 at 9:14
• @LLlAMnYP Feel free to rollback my edit. It looks like the problem you describe may be separate from the crashes I experience with version 10.4.1 (but may be not - we can't be sure). In the previous comment you wrote that MMA 10.4.0 takes a lot of memory, so it doesn't crash? So you have a wrong rendering with versions 10.1 and 10.2 and the memory issue with version 10.4.0? Please include this information in the question and also a screenshot(s) the FrontEnd with "an empty box with a tiny little square" instead of the expected output in order to make the question more precise. – Alexey Popkov Aug 1 '16 at 9:26

With Mathematica 10.4.1 on Windows 7 x64 I get FrontEnd crash with your code by default but switching to "Graphics3DRenderingEngine" -> "BSPTree" produces the expected output which is relatively responsible (comparing to the Image3D):

SeedRandom[10]
i3d = 1/4 RandomReal[1, {5, 5, 5}] // Image3D


Style[Show[{i3d, Graphics3D[{FaceForm[Opacity[.6]], Cuboid[{3, 3, 3}]}]}],
RenderingOptions -> {"Graphics3DRenderingEngine" -> "BSPTree"}]


The option RenderingOptions -> {"Graphics3DRenderingEngine" -> "Software"} produces the same but seems to be even slower.

An attempt to Export this as PNG with ImageSize -> {2400, 1600} crashed my video driver and I got not responding FrontEnd taking 100% CPU time of one of my cores. So at least my graphical card doesn't allow to render such a large image.

As a workaround you can try to apply an incremental rendering technique. This post of mine (see the "EDIT 4" section) shows Inset-based approach, another method is suggested by Vitaliy Kaurov (search for "3dImagePartitionExport.nb" in this Wolfram Community thread).

• Woah. I just added the details. Did you pass the ImageSize option to Export? What happens if you pass it to Show? +1 for the option, I'll toy with that. – LLlAMnYP Aug 1 '16 at 9:58
• I passed the option via Show as in the question. I have just added possible workarounds at the bottom of my answer. – Alexey Popkov Aug 1 '16 at 10:00
• Your workaround (I mean the non-default rendering engine) with hi-res rendering on 10.2 works for me. – LLlAMnYP Aug 1 '16 at 10:05
• For the record, the cluster managed fine for a {4800,3200} resolution in 10.0. I don't know the details of their GPU though. – LLlAMnYP Aug 1 '16 at 10:07
• And I have just verified, that the non-default engine also works ok for my larger problem, not just the MWE, though it did freeze the notebook for about a minute. I think, this is grounds to accept the answer, pending a future answer that reports a bugfix. – LLlAMnYP Aug 1 '16 at 10:12