I'm trying to make a ContourPlot3D
that needs to be transparent. With transparency, however, something odd happens.
With PerformanceGoal->"Speed"
, the colors look fine.
With PerformanceGoal->"Quality"
, the colors are all mottled.
My actual code is more complicated than what I've shown here, but I've tried to reduce it to (nearly?) the simplest case that still produces the error.
I have a function:
my3DGauss[x_, y_, z_] := Exp[-(x^2 + y^2 + z^2)/2];
I try to make a transparent 3D contour plot of it:
ContourPlot3D[my3DGauss[x, y, z], {x, -3, 3}, {y, -3, 3}, {z, -3, 3},
Contours -> {0.1, 0.2, 0.4, 0.7},
RegionFunction -> Function[{x, y, z}, x > 0], Mesh -> None,
ColorFunction -> (ColorData[{"AlpineColors", "Reverse"}][#4] &),
ContourStyle -> Directive[Opacity[0.8], Specularity[White, 30]],
PerformanceGoal -> "Speed"]
This renders fine (if jagged).
If I try to make a quality plot though, the results look horrible:
ContourPlot3D[my3DGauss[x, y, z], {x, -3, 3}, {y, -3, 3}, {z, -3, 3},
Contours -> {0.1, 0.2, 0.4, 0.7},
RegionFunction -> Function[{x, y, z}, x > 0], Mesh -> None,
ColorFunction -> (ColorData[{"AlpineColors", "Reverse"}][#4] &),
ContourStyle -> Directive[Opacity[0.8], Specularity[White, 30]],
PerformanceGoal -> "Quality"]
The colors are all mottled, with off-color artifacts reminiscent of what is presumably the underlying mesh (which has been suppressed in output).
Things I have tried:
- Increasing
PlotPoints
- Increasing
MaxRecursion
- Increasing
MaxPoint
- Using an indexed list of colors instead of a
ColorFunction
- Specifying the opacity various ways (e.g. in a list of colors, instead of
ContourStyle
Directive) - Using
LegacyAlphaChannel
option underRenderingOptions
- Playing with
3DRenderingEngine: "Direct3D", "Mesa"
- Playing with
3DRenderingMethod: "HardwareDepthBuffer", "HardwareDepthPeeling", "BSPTree"
- Other things not worth mentioning here
Option (4) seemed like a no-fail work-around. It got rid of the mottling, but a new problem arose: the colors were all off (they all looked bizarrely orangey).
Fun irrelevant fact, I have been using Mathematica since 2.0, and this is my first SE question. :)
I decided this must be a bug, and so I was hoping that when I upgraded from 11.0 -> 12.0 it would fix it. No such luck.
System: Windows 10. NVIDIA Quadro P1000 graphics card.
Planning on trying this in Linux and/or cloud-based (?) Mathematica, which I haven't tried yet.
Thanks, Peter