You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
BUG: Opacity of streamlines interacting with visual ordering of visualization modules #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.
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.
changed the title [-]Opacity of streamlines interacting with visual ordering of visualization modules[/-][+]BUG: Opacity of streamlines interacting with visual ordering of visualization modules[/+]on Mar 6, 2017
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.
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:
scene = mlab.gcf().scene
scene.renderer.set(use_depth_peeling=True)
which I adapted from this question about a similar issue..
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?
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:
deforderTransparentRender(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=lambdax:-1*x[0][2])
cz=zip(*cz)
returncz[0],cz[1]
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.
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>
.
Activity
[-]Opacity of streamlines interacting with visual ordering of visualization modules[/-][+]BUG: Opacity of streamlines interacting with visual ordering of visualization modules[/+]Mallcock1 commentedon Apr 7, 2017
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
luukko commentedon May 10, 2017
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.
jeswcollins commentedon Sep 24, 2017
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.
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.
prabhuramachandran commentedon Sep 24, 2017
You probably need to set the front-face culling option on. Try this:
jeswcollins commentedon Sep 24, 2017
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:
https://www.vtk.org/Wiki/VTK/Examples/Cxx/Visualization/CorrectlyRenderingTranslucentGeometry
https://www.vtk.org/Wiki/VTK/Depth_Peeling
And a couple links I used for reproducing the sphere case:
https://lorensen.github.io/VTKExamples/site/Python/GeometricObjects/Sphere/
https://www.vtk.org/Wiki/VTK/Examples/Cxx/Visualization/Opacity
Mallcock1 commentedon Sep 25, 2017
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..
jeswcollins commentedon Sep 29, 2017
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?
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:
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
ziphere: https://stackoverflow.com/questions/1663807/how-can-i-iterate-through-two-lists-in-parallelprabhuramachandran commentedon Aug 26, 2018
With recent VTK versions this works well for me:
Also, there is an
f.scene.renderer.maximum_number_of_peelsthat 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.
Mallcock1 commentedon Aug 26, 2018
prabhuramachandran commentedon Aug 26, 2018
Great, thanks.
Fix 3D object ordering when opacity is reduced