Skip to content

Depth Peeling #450

Merged
banesullivan merged 8 commits intomasterfrom
depth_peeling
Nov 20, 2019
Merged

Depth Peeling #450
banesullivan merged 8 commits intomasterfrom
depth_peeling

Conversation

@GuillaumeFavelier
Copy link
Copy Markdown
Contributor

This PR adds enable_depth_peeling() and disable_depth_peeling() functions to the BasePlotter API. There is also check_depth_peeling() in pyvista.utilities. This is strongly inspired by the material provided in lorensen.github.io about translucent geometry.

Closes #437

@GuillaumeFavelier
Copy link
Copy Markdown
Contributor Author

What do you think @banesullivan, @akaszynski, @keltonhalbert?

@aashish24
Copy link
Copy Markdown

nice contribution @GuillaumeFavelier

@banesullivan banesullivan self-requested a review November 18, 2019 22:28
@banesullivan banesullivan added this to the 0.23.0 milestone Nov 18, 2019
if hasattr(self, 'ren_win') and depth_peeling_supported:
self.multi_samples = self.ren_win.GetMultiSamples()
self.ren_win.AlphaBitPlanesOn()
self.ren_win.SetMultiSamples(0)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I'm starting to think that setting the multi-samples to zero isn't needed... or that it might not matter as the multi-samples need to be set before the first render. I deleted this line locally and couldn't tell a difference in the output.

When I added #365, I remember finding some VTK docs about how the multi-samples needs to be set before the first render. At the moment, all I'm digging up is this thread: https://vtk.org/pipermail/vtkusers/2017-November/100211.html

Make sure you set it before your first render, it is used when creating the
hardware window.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay then, I'll remove it right away

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It didn't change anything in my local example as well 👍

Copy link
Copy Markdown
Member

@banesullivan banesullivan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me!

"""Disables depth peeling."""
if hasattr(self, 'multi_samples') and hasattr(self, 'ren_win'):
self.ren_win.AlphaBitPlanesOff()
self.ren_win.SetMultiSamples(self.multi_samples)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If anything changes in my above comment, this would need to be updated

@banesullivan
Copy link
Copy Markdown
Member

I just added an example to showcase the differences which are pretty compelling:

sphx_glr_depth-peeling_001
sphx_glr_depth-peeling_002

@akaszynski akaszynski self-requested a review November 18, 2019 23:04
Copy link
Copy Markdown
Member

@akaszynski akaszynski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Thanks for the pr @GuillaumeFavelier.

@GuillaumeFavelier
Copy link
Copy Markdown
Contributor Author

I was struggling to find a good way to demonstrate depth peeling in the doc, thanks for the nice example @banesullivan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Changes that enhance the library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable Depth Peeling to avoid opacity issues

4 participants