15
$\begingroup$

In Mathematica 12.1 if I try use Opacity less than 1, it does not work.

Graphics3D[{Opacity[0.1],Sphere[]}]

Plot3D[Sin[x + y^2], {x, -3, 3}, {y, -2, 2}, PlotStyle -> Opacity[0.8]]

Even if I try to execute Opacity-related example from the documentation it does not work. I am using Mathematica 12.1 in Linux by the way.

screenshot

$\endgroup$
11
  • 3
    $\begingroup$ Maybe provide some code of what you are trying to do, what you expect, an what you are seeing. Simply saying "it doesn't work", doesn't give anyone much to work off! $\endgroup$
    – user27119
    Commented May 10, 2020 at 17:50
  • $\begingroup$ Sorry. Its actually opacity under Plot3D or Graphics3D not working. Say, Plot3D[Sin[x + y^2], {x, -3, 3}, {y, -2, 2}, PlotStyle -> Opacity[0.8]] this code , it returns a blank box , but changing opacity to 1 it shows the sphere $\endgroup$
    – puppet22
    Commented May 10, 2020 at 17:52
  • 1
    $\begingroup$ This looks like one of those times where a screenshot, as well as the code you are evaluating (in copyable form) should be supplied. $\endgroup$ Commented May 10, 2020 at 17:54
  • 2
    $\begingroup$ When I said copyable code, this is like the code from your comment that I added to your question. Next time, please do this yourself. $\endgroup$ Commented May 10, 2020 at 18:00
  • 1
    $\begingroup$ You should contact Wolfram with this. $\endgroup$
    – Szabolcs
    Commented May 10, 2020 at 18:28

4 Answers 4

11
$\begingroup$

I contacted Wolfram, and they told me another workaround that doesn't require using the -mesa option (which removes antialiasing and is slow since it renders on the CPU). You can use HardwareDepthPeeling like in:

Style[
  Plot3D[Sin[x + y^2], {x, -3, 3}, {y, -2, 2},PlotStyle -> Opacity[0.3]],
  RenderingOptions -> {"3DRenderingMethod" -> "HardwareDepthPeeling"}
]

This can be enabled globally in the Options Inspector:

Edit -> Preferences -> Advanced -> Open Option Inspector
Graphics Options -> RendreingOptions -> "3DRenderingMethod" -> "HardwareDepthPeeling"
$\endgroup$
6
$\begingroup$

I was able to fix the Opacity issue in Manjaro KDE (Kernel: 5.4.40-1) going to the Option Inspector to modify the settings for:

Graphics Options > RenderingOptions > "Graphics3DRenderingEngine"

to change from > "Automatic" to > "Mesa". The other option available: "OpenGL" doesn't work and I do not really know whether it should or what does it mean. Also a font rendering issue for the labels in Plot3D was fixed in this way.

Additional comments related to this issue are more than welcome.

$\endgroup$
6
  • 3
    $\begingroup$ There's also the old solution of starting Mathematica as mathematica -mesa from e.g. the command line. $\endgroup$ Commented May 22, 2020 at 1:51
  • $\begingroup$ For me the -mesa solution did work as well but the rendering was quite underwhelming. If you have a dedicated Nvidia GPU like I do, you can make use of bumblebee (uses dGPU only on demand to save power). Just start the binary via command line with primusrun mathematica &. $\endgroup$ Commented Jun 21, 2020 at 19:59
  • 1
    $\begingroup$ This solution didn't actually work for me $\endgroup$ Commented Aug 11, 2020 at 0:32
  • $\begingroup$ To save someone some time: Option inspector is by default opened using Shift+Ctrl+O. You need to set "shop options value" to global if you want to fix this globally. It works for me Ubuntu 20.04. I am not sure whether it has a detrimental effect on rendering time and output. $\endgroup$
    – Kvothe
    Commented Dec 10, 2020 at 16:26
  • 1
    $\begingroup$ The solution above worked for me but brought about new problems with plotting especially in 3D. In the end I managed to solve this problem and the new once I encountered after switching by switching back to OpenGL AND changing my GPU drivers from the open source nouveau ones that come with Ubuntu to the proprietary Nvidia drivers. Now everything seems to work (for now). See mathematica.stackexchange.com/a/255306/45020 $\endgroup$
    – Kvothe
    Commented Sep 6, 2021 at 11:35
4
$\begingroup$

Your code works fine on version 12.1 with my Mac, using OS Catalina 10.15.3:

Graphics3D[{Opacity[0.1], Sphere[]}]

enter image description here

Plot3D[Sin[x + y^2], {x, -3, 3}, {y, -2, 2}, PlotStyle -> Opacity[0.8]]

picture

$\endgroup$
10
  • $\begingroup$ I am using Linux (Manjaro 20.0). Here the opacity is not working! $\endgroup$
    – puppet22
    Commented May 10, 2020 at 18:23
  • 8
    $\begingroup$ Sounds like you should inform Wolfram Research. $\endgroup$
    – DavidC
    Commented May 10, 2020 at 19:11
  • 1
    $\begingroup$ Or change the Linux distribution. This works all fine on Mathematica 12.1 on CentOS and Ubuntu. $\endgroup$ Commented May 12, 2020 at 13:37
  • $\begingroup$ @RolfMertig what Linux kernel version are you using ? $\endgroup$
    – puppet22
    Commented May 13, 2020 at 21:30
  • $\begingroup$ @puppe22: 2.6 and 5.0. I doubt it has anything to do with the kernel version. Maybe your you windows manager or your graphics card matters? XFCE or what do you use? $\endgroup$ Commented May 13, 2020 at 22:10
1
$\begingroup$

If you have problems with Opacity and you are using a Linux system with a Nvidia graphics card:

I had the same problem and initially followed the answer by Bob. However, while the Mesa engine did fix the Opacity issue it introduced other problems. In the end I managed to fix all problems by instead changing the drivers for my GPU from the open source nouveau ones that come with Ubuntu to the proprietary Nvidia ones. With the Nvidia drivers OpenGL correctly showed transparent surfaces and no new problems have arisen (yet).

To switch symply go to the additional drivers application and it should show you the available drivers for your Nvidia GPU.


See also this related answer https://mathematica.stackexchange.com/a/255306/45020

$\endgroup$

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.