question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Depth peeling not functioning with xvfb

See original GitHub issue

Describe the bug, what’s wrong, and what you expect:

A clear and concise description of what the bug is.

I frequently use Pyvista to plot multiple 2D meshes on top of each other that are partially transparent. I find that the transparency only renders correctly when depth peeling is enabled. However, I recently needed to do some plotting on a remote machine (using xvfb) and find that transparent meshes will not render at all if depth peeling is enabled.

A clear and concise description of what you expected to happen.

I expect when using xvfb in conjunction with depth peeling on a headless machines for transparency/opacity to render correctly. I provide an example code below using the planefile example.


To Reproduce

Please include a code snippet to reproduce the bug in the block below:

"""
Test for opacity on headless machine
"""

import pyvista as pv
from pyvista import examples

pv.start_xvfb()

mesh = pv.read(examples.planefile)

plotter = pv.Plotter(off_screen=True)
plotter.enable_depth_peeling()    

plotter.add_mesh(mesh, opacity=0.5)

plotter.show(screenshot='test.png')

Screenshots Resulting screenshot using the code above: test_depth_peeling

Screenshot with depth peeling disabled: test_nodepthpeeling


System Information: Please run the following code wherever you are experiencing the bug and paste the output below. This report helps us track down bugs and it is critical to addressing your bug:

# Get system info
import pyvista as pv
print(pv.Report())
--------------------------------------------------------------------------------
  Date: Thu May 12 17:37:55 2022 PDT

                OS : Linux
            CPU(s) : 16
           Machine : x86_64
      Architecture : 64bit
               RAM : 27.3 GiB
       Environment : Python
       File system : ext4
       GPU Details : error

  Python 3.9.12 | packaged by conda-forge | (main, Mar 24 2022, 23:25:59)
  [GCC 10.3.0]

           pyvista : 0.34.0
               vtk : 9.1.0
             numpy : 1.22.3
           imageio : 2.19.1
           appdirs : 1.4.4
            scooby : 0.5.12
        matplotlib : 3.5.2
             PyQt5 : 5.12.3
           IPython : 7.33.0
             scipy : 1.8.0
              tqdm : 4.64.0

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
akaszynskicommented, Aug 8, 2022

I’m having the exact same problem with mayavi, I believe it is a problem with vtk/Xvfb. Is there any alternative to Xvfb for headless rendering?

Yes, OSMesa, see https://github.com/pyvista/pyvista-wheels

0reactions
lopsidedcommented, Aug 10, 2022

[Duplicating my 2 comments from https://github.com/enthought/mayavi/issues/1165]

TL;DR: export GALLIUM_DRIVER=softpipe fixes the problem.

The problem appears to be with the renderer. When using Xvfb you don’t get the hardware support so even with a GPU on the headless machine you can’t use it (AFAICT). That means you’re using the software renderer llvmpipe by default. This can be changed to swr or softpipe (I found this from here: https://www.paraview.org/Wiki/ParaView/ParaView_And_Mesa_3D). I couldn’t get swr to work but setting it to softpipe resolves the issue. Obviously don’t expect the performance to be good using this option.

In an attempt to fix gpu support I tried running a full X server on my machine, which shows up as a process in nvidia-smi and gives me OpenGL renderer string: Quadro RTX 4000/PCIe/SSE2 as output to glxinfo | grep -i render. However I still need this fix to use depth peeling, so I’m not actually sure if I’m getting any gpu rendering here or not.

– Update – OK in a last attempt, I installed the llvm-dev package (https://docs.mesa3d.org/drivers/llvmpipe.html) and reinstalled all my conda packages. Nope, GALLIUM_DRIVER=llvmpipe still fails under Xvfb.

BUT (I’m sure coincidentally) now my gpu-aware Xorg server now renders correctly with any setting of GALLIUM_DRIVER (including the previously crashing swr) so I appear to have at least got gpu rendering working.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues with Depth Peeling when used in Qt Quick - GitLab
Our software depends on depth peeling for transparency. ... Quick because nothing is rendered correctly, not even other Qt Quick components.
Read more >
17453 – Xvfb doesn't work at depth 32 - freedesktop.org Bugzilla
I test with a python program called 'pyglet' that is a wrapper around OpenGL. This is on a headless EC2 Ubuntu 9.04 box...
Read more >
vedo API documentation
A python module for scientific analysis of 3D objects and point clouds based on VTK and numpy. Install and Test. pip install vedo...
Read more >
Source code for pyvista.themes
_enabled = False @property def number_of_peels(self) -> int: """Return or set the number of peels in depth peeling. Examples -------- >>> import pyvista ......
Read more >
Untitled
My pendrive is not working in laptop, Slane strudle recepti, Islay mist blended scotch whisky, ... Muzikines klausos testas, Enzyme peel definition.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found