Opacity=1 makes objects black on my system

41 views
Skip to first unread message

Rita Bylsma

unread,
Apr 21, 2024, 6:55:48 AMApr 21
to VPython-users
Hi,
I just installed vpython on Manjaro Linux and I am using firefox.
The standard example shows nothing:
echo 'from vpython import *; sphere()' | python

I found that this is because the default opacity == 1, while that opacity does not work,
it causes the objects to come out black.

Please compare:
echo 'from vpython import *;sphere(opacity=0.8); cylinder(opacity=0.9999)' | python
echo 'from vpython import *;sphere(opacity=0.8); cylinder(opacity=1)' | python
echo 'from vpython import *;sphere(opacity=0.8); cylinder(opacity=0)' | python

The first works as expected, showing the white cylinder and half of the white sphere, transparent, so looking gray, as the background is black.
The second should look the same, but actually does not show the cylinder, allthough it hides half of the sphere, as expected, but with black.
The third does almost what is expected, not showing the cylinder, but showing an ugly, ragged edge on the sphere.  But maybe that is normal, due to rounding errors ...
  
Environment:
Manjaro Linux, upto date
Python version is 3.11.8. 
vpython version is 7.6.5
I installed vpython as a user, with pipx
Then I set:
PATH=$HOME/.local/share/pipx/shared/bin:$PATH
export PYTHONPATH=$HOME/.local/share/pipx/shared/lib/python3.11/site-packages/
I also get this warning:
'ATTENTION: default value of option mesa_glthread overridden by environment.'
Which also shows that I am running mesa here, which might not be sophisticated enough for vpython.  However, I noticed no other problems (but we do no fancy graphical stuff, besides vpython).
  
Best Regards and many thanks for vpython,
                                                                               Rita Bylsma

Bruce Sherwood

unread,
Apr 21, 2024, 12:02:44 PMApr 21
to VPython-users
I know nothing about mesa, nor about "echo". When I run the following program, there is no difference between the first and the second spheres and cylinders:

from vpython import *
scene.height=800
sphere(opacity=0.8)
cylinder(opacity=0.9999)
sphere(pos=vec(0,-1,0), opacity=0.8)
cylinder(pos=vec(0,-1,0), opacity=1)

In the case of setting the cylinder opacity to 0, yes, I do see a crack around the sphere, however the standard way to make an object invisible in VPython is not to set opacity to 0 but to set visible to 0.

Bruce

Rita Bylsma

unread,
Apr 21, 2024, 1:12:10 PMApr 21
to VPython-users

Hi Bruce,
Thank you for your answer.  With echo I fed that same code to python.
I now executed the code as you typed it.
I have the same problem with opacity = 1
(I mentioned the opacity == 0 only to cover all of opacity)  

I include a screenshot of it.
So that must be a problem of my graphics driver (mesa) or my graphics card ...
The graphics card is quite new, but mesa is kind of a fall back driver (if I remember correctly)
I will investigate this further when I have time, but I do have a workaround now...
Op zondag 21 april 2024 om 18:02:44 UTC+2 schreef bruce.s...@gmail.com:
2024-04-21-190411_548x601_scrot.png

Bruce Sherwood

unread,
Apr 21, 2024, 8:49:42 PMApr 21
to VPython-users
Of course setting opacity=1 should have absolutely no effect, since that's the default.

Bruce

Rita Bylsma

unread,
Apr 22, 2024, 5:14:55 AMApr 22
to VPython-users
It indeed has no effect on my system.  Without an opacity argument it gives the same bad result: having the color opaque black, regardless of color settings.  That is why on my system, the most easy examples of the vpython documentation show nothing at all, as the background is also black by default.  That makes it difficult to understand what is going on.
So, if this is indeed a problem of my graphics driver, it is important to note systemrequirements regarding the driver, in the vpython documentation.  It may also be good to have the default background something else, like sky color, or dark gray instead of black.  Then, it will at least be clear that something is actually drawn ...

Best Regards,
Rita Bylsma

Op maandag 22 april 2024 om 02:49:42 UTC+2 schreef bruce.s...@gmail.com:

Bruce Sherwood

unread,
Apr 22, 2024, 12:39:55 PMApr 22
to VPython-users
The default color of objects is white, which is why the default background color is black. So no, we're not going to change these defaults, given the huge number of programs written in the 24 years of VPython's existence.

You might go to https://get.webgl.org/webgl2/ which checks whether WebGL2works properly. WebGL2 is the browser package used by VPython.

Bruce
Reply all
Reply to author
Forward
0 new messages