Skip to content

Commit f722e74

Browse files
Fix ssao
1 parent 5860302 commit f722e74

1 file changed

Lines changed: 39 additions & 15 deletions

File tree

mne/viz/backends/_pyvista.py

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -848,21 +848,45 @@ def _silhouette(self, mesh, color=None, line_width=None, alpha=None,
848848
prop.SetLineWidth(line_width)
849849

850850
def _enable_ssao(self, dataset):
851-
# MWE that reproduces the visual artifact:
852-
basic_pass = vtk.vtkRenderStepsPass()
853-
self.plotter.renderer.SetPass(basic_pass)
854-
855-
# minimal code to enable SSAO:
856-
# basic_pass = vtk.vtkRenderStepsPass()
857-
# bounds = np.asarray(dataset.GetBounds())
858-
# scene_size = np.linalg.norm(bounds[:3] - bounds[3:])
859-
# ssao = vtk.vtkSSAOPass()
860-
# ssao.SetRadius(0.1 * scene_size) # comparison radius
861-
# ssao.SetBias(0.001 * scene_size) # comparison bias
862-
# ssao.SetKernelSize(128) # number of samples used
863-
# ssao.BlurOff() # do not blur occlusion
864-
# ssao.SetDelegatePass(basic_pass)
865-
# self.plotter.renderer.SetPass(ssao)
851+
lightsP = vtk.vtkLightsPass()
852+
opaqueP = vtk.vtkOpaquePass()
853+
translucentP = vtk.vtkTranslucentPass()
854+
volumeP = vtk.vtkVolumetricPass()
855+
856+
collection = vtk.vtkRenderPassCollection()
857+
collection.AddItem(lightsP)
858+
859+
# opaque passes
860+
ssaoCamP = vtk.vtkCameraPass()
861+
ssaoCamP.SetDelegatePass(opaqueP)
862+
863+
bounds = np.asarray(dataset.GetBounds())
864+
scene_size = np.linalg.norm(bounds[:3] - bounds[3:])
865+
ssaoP = vtk.vtkSSAOPass()
866+
ssaoP.SetRadius(0.1 * scene_size) # comparison radius
867+
ssaoP.SetBias(0.001 * scene_size) # comparison bias
868+
ssaoP.SetKernelSize(128) # number of samples used
869+
ssaoP.BlurOff() # do not blur occlusion
870+
ssaoP.SetDelegatePass(ssaoCamP)
871+
collection.AddItem(ssaoP)
872+
873+
# translucent and volumic passes
874+
ddpP = vtk.vtkDualDepthPeelingPass()
875+
ddpP.SetTranslucentPass(translucentP)
876+
ddpP.SetVolumetricPass(volumeP)
877+
collection.AddItem(ddpP)
878+
879+
# finally overlays
880+
overP = vtk.vtkOverlayPass()
881+
collection.AddItem(overP)
882+
883+
sequence = vtk.vtkSequencePass()
884+
sequence.SetPasses(collection)
885+
886+
camP = vtk.vtkCameraPass()
887+
camP.SetDelegatePass(sequence)
888+
889+
self.plotter.renderer.SetPass(camP)
866890

867891

868892
def _compute_normals(mesh):

0 commit comments

Comments
 (0)