-
Notifications
You must be signed in to change notification settings - Fork 286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BUG: Opacity of streamlines interacting with visual ordering of visualization modules #491
Comments
Is this an issue which will be fixable in the near future? If not, I would appreciate knowing so that I can find another way around my problem. Thank you |
This seems to apply to other objects as well. I'm using contour3d with points3d and setting the opacity of the points to anything other than 1.0 causes the surface not to obscure them anymore. |
I see what I think is the same issue with two points3d objects. Here are some examples showing how the appearance of 2 spheres rendered depends on rendering order if the opacity is set to .99, but not if opacity is set to 1. mlab.figure()
mlab.points3d(0,0,1,color=(.8,.8,.8),resolution=100,opacity=.99)
mlab.points3d(0,0,0,color=(.8,.8,.8),resolution=100,opacity=.99) mlab.figure()
mlab.points3d(0,0,0,color=(.8,.8,.8),resolution=100,opacity=.99)
mlab.points3d(0,0,1,color=(.8,.8,.8),resolution=100,opacity=.99) mlab.figure()
mlab.points3d(0,0,1,color=(.8,.8,.8),resolution=100)
mlab.points3d(0,0,0,color=(.8,.8,.8),resolution=100) mlab.figure()
mlab.points3d(0,0,0,color=(.8,.8,.8),resolution=100)
mlab.points3d(0,0,1,color=(.8,.8,.8),resolution=100) The issue does not seem to depend on choice of lights or light_manager ('vtk' or 'raymond'). I suppose one workaround may be first sorting the objects to be rendered by their depth along an axis into or out of the screen. |
You probably need to set the front-face culling option on. Try this:
|
Thanks Prabhu---I think the frontface_culling improved the visuals, but the rendering order still was a factor only in the semi-transparent case. I reproduced that observation in vtk alone (it's a lower level issue). After more reading, I think there is a solution or two built into vtk, but another solution may be to sort the objects before rendering. Here are a couple links about vtk that seemed relevant: And a couple links I used for reproducing the sphere case: |
Thanks for adding to the discussion and for the helpful links. I am not very knowledgeable about VTK or depth peeling, but a simple solution that I found that worked for my original example and the project I am working on was to include this:
which I adapted from this question about a similar issue.. |
Thanks for the help Matt and Prabhu. I tried depth_peeling, which for my actual use case is more helpful than it is for this 2 sphere example. But compared to reordering the spheres, the edges seem less...anti-aliased I think might be the term? f=mlab.figure()
f.scene.renderer.use_depth_peeling=1
g0=mlab.points3d(0,0,1,color=(.8,.8,.8),resolution=100,opacity=.99)
g1=mlab.points3d(0,0,0,color=(.8,.8,.8),resolution=100,opacity=.99)
g0.actor.property.frontface_culling = True
g1.actor.property.frontface_culling = True For my 3d plotting, I have a list of points and a list of colors. So instead of depth peeling I used this function to reorder those lists together before plotting: def orderTransparentRender(cl,c):
'''Opacity < 1 rendering results in appearance of spheres incorrectly in front of or behind other spheres
One solution is setting f.scene.renderer.use_depth_peeling=1, however this seemed to result in less anti-aliased edges?
This function sorts the cluster list cl and color list c together.
'''
cz=zip(cl,c)
cz=sorted(cz,key=lambda x:-1*x[0][2])
cz=zip(*cz)
return cz[0],cz[1] Otherwise the sorted call could be all that's required. I learned that from the python docs: https://wiki.python.org/moin/HowTo/Sorting. I learned about python's |
With recent VTK versions this works well for me:
Also, there is an May I close this issue? I think this does seem to fix many problems I have seen before. |
Thank you. I will be able to work with this. You can close this issue.
Matthew Allcock | PhD researcher
University of Sheffield | School of Mathematics and Statistics
www.matthewallcock.co.uk
…On Sun, 26 Aug 2018, 21:55 Prabhu Ramachandran, ***@***.***> wrote:
With recent VTK versions this works well for me:
from mayavi import mlab
f = mlab.figure()
mlab.points3d(0,0,1,color=(.8,.8,.8),resolution=100,opacity=.99)
mlab.points3d(0,0,0,color=(.8,.8,.8),resolution=100,opacity=.99)
f.scene.renderer.use_depth_peeling = True
Also, there is an f.scene.renderer.maximum_number_of_peels that you could
potentially use. It is 4 by default but you could set it to zero for no
limit although this will slow down rendering. You could tinker with this.
May I close this issue? I think this does seem to fix many problems I have
seen before.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#491 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AP4RUC8AYAnDAV6-wE88hHw5cPP-x01gks5uUwtGgaJpZM4MT7Rp>
.
|
Great, thanks. |
Reducing opacity by any amount causes front 3D objects in Mayavi to appear behind deeper surfaces from some angles. Turn on depth peeling after rendering 3D surfaces or points to fix this ordering as described in this issue: enthought/mayavi#491 .
Changing the opacity of streamlines to anything other than its default value (1.0) brings the streamlines to the front of the scene even when there are other objects that should obscure them.
For example, I refer you to the magnetic fieldline example given here: http://docs.enthought.com/mayavi/mayavi/auto/example_magnetic_field_lines.html.
Running the code as it is gives the following scene:
However, if we change the opacity of the fieldlines so that it is different it its default value of 1.0 (either by adding
field_lines.actor.property.opacity = 0.99
or by manually adjusting the opacity in the Mayavi pipeline) we get something like the following scene:The fieldlines are now at the front of the scene, however the isocontours should still obscure then like in the previous image.
The text was updated successfully, but these errors were encountered: