Closed filip-halemba closed 4 years ago
Is there any downside to enabling backface culling by default?
I thought that there were some cases when the brain was partially transparent where it seemed better to have it off. So one option is to enable backface culling when the brain alpha is 1. and disable it otherwise. @wmvanvliet since you can replicate do you want to try?
I've done some digging around. Unfortunately, the problem goes deeper than backface culling. There is a bug in Qt5 regarding obtaining an OpenGL rendering context with a depth buffer. Somehow, for some non-nvidia chipsets, Qt5 creates a context without depth buffering. Hence vertices are rendered in the wrong order. Hence bad rendering bugs like we see in this issue. Here is a clue:
Temporary fix is to switch Mayavi over to the wx
rendering engine. But that has problems of its own.
Backface culling removes a lot of vertices from the render queue and hence alleviates the problems a bit.
The only other idea I have is trying to tweak the OpenGL rendering to set the polygon offset (negative values for the ones we want on top) and enabling polygon offset for fill mode. Not sure if this requires a functional depth buffer but it might.
Here's how things look with a non-nvidia card. It's not limited to just the overlay:
No offset fill is going to save you from that :(
If a usable workaround is actually to use a QVTKWidget2
instead of QVTKWidget
, then we could try updating mayavi
to use this newer widget. We could also see if PyVista
could make a corresponding change. There have been depth problems in mne coreg
that would might also be fixed by such a change.
Way ahead of you :) Mayavi, well pyface, doesn't use QVTKWidget
directly, but does it's own thing on top of QGLWidget
: https://github.com/enthought/mayavi/blob/master/tvtk/pyface/ui/qt4/QVTKRenderWindowInteractor.py
Cross-ref to https://github.com/pyvista/pyvista/issues/473. Maybe the fix there combined with using VTK 8.2+ would fix things.
(on my VTK 8.1.2 and NVIDIA hardware my QVTKRWIBase
is 'QWidget'
)
It would be awesome if we could solve this!
@wmvanvliet you can try conda-forge to see if the 8.2 they have up there can be used:
https://anaconda.org/conda-forge/vtk/files
It might automatically work, and if not, maybe look into what they did in pyvista/pyvista#473 to fix things...
During visualization of inverse problem with mne-python I produced "leaky" picture like in picture below.
I started to asking question on gitter where @larsoner put some advice for me. After few days I resolved my problem by enabling
backface culling
for the overlay.This task was created at the request of @larsoner - https://gitter.im/mne-tools/mne-python?at=5e3899b1e8a838355913a83a