Mayavi: BUG:与可视化模块的视觉排序交互的流线的不透明度

创建于 2017-03-06  ·  10评论  ·  资料来源: enthought/mayavi

将流线的不透明度更改为默认值 (1.0) 以外的任何值,即使存在其他应遮挡它们的对象,也会将流线带到场景的前面。

例如,我向您推荐这里给出的磁场线示例: http ://docs.enthought.com/mayavi/mayavi/auto/example_magnetic_field_lines.html

按原样运行代码会得到以下场景:
test_bug_1

但是,如果我们更改场线的不透明度,使其与默认值 1.0 不同(通过添加field_lines.actor.property.opacity = 0.99或通过在 Mayavi 管道中手动调整不透明度),我们会得到类似以下场景的内容:
test_bug_2
场线现在位于场景的前面,但是等高线应该仍然像上一张图​​像一样模糊。

最有用的评论

使用最近的 VTK 版本,这对我来说效果很好:

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

此外,您还可以使用f.scene.renderer.maximum_number_of_peels 。 默认情况下为 4,但您可以将其设置为零以表示没有限制,尽管这会减慢渲染速度。 你可以摆弄这个。

我可以关闭这个问题吗? 我认为这似乎确实解决了我以前见过的许多问题。

所有10条评论

这是一个可以在不久的将来解决的问题吗? 如果没有,我将不胜感激,这样我就可以找到解决问题的另一种方法。 谢谢

这似乎也适用于其他对象。 我正在使用带有 points3d 的轮廓 3d 并将点的不透明度设置为 1.0 以外的任何值会导致表面不再遮挡它们。

我看到我认为两个 point3d 对象存在相同的问题。 下面是一些示例,显示了在不透明度设置为 0.99 时渲染的 2 个球体的外观如何取决于渲染顺序,但在不透明度设置为 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)

2

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)

4

mlab.figure()
mlab.points3d(0,0,1,color=(.8,.8,.8),resolution=100)
mlab.points3d(0,0,0,color=(.8,.8,.8),resolution=100)

1

mlab.figure()
mlab.points3d(0,0,0,color=(.8,.8,.8),resolution=100)
mlab.points3d(0,0,1,color=(.8,.8,.8),resolution=100)

3

该问题似乎并不取决于灯光或 light_manager(“vtk”或“raymond”)的选择。

我想一种解决方法可能是首先将要渲染的对象沿轴进出屏幕的深度进行排序。

您可能需要设置正面剔除选项。 尝试这个:

mlab.figure()
g1 = mlab.points3d(0,0,1,color=(.8,.8,.8),resolution=100,opacity=.99)
g2 = mlab.points3d(0,0,0,color=(.8,.8,.8),resolution=100,opacity=.99)
g1.actor.property.frontface_culling = True
g2.actor.property.frontface_culling = True

谢谢 Prabhu ---我认为 frontface_culling 改进了视觉效果,但渲染顺序仍然是仅在半透明情况下的一个因素。

我仅在 vtk 中重现了该观察结果(这是一个较低级别的问题)。

经过更多阅读,我认为 vtk 中内置了一两个解决方案,但另一种解决方案可能是在渲染之前对对象进行排序。

以下是一些关于 vtk 的链接,它们似乎相关:
https://www.vtk.org/Wiki/VTK/Examples/Cxx/Visualization/CorrectlyRenderingTranslucentGeometry
https://www.vtk.org/Wiki/VTK/Depth_Peeling

还有一些我用来复制球体案例的链接:
https://lorensen.github.io/VTKExamples/site/Python/GeometricObjects/Sphere/
https://www.vtk.org/Wiki/VTK/Examples/Cxx/Visualization/Opacity

感谢您加入讨论并提供有用的链接。 我对 VTK 或深度剥离不是很了解,但是我发现一个简单的解决方案适用于我的原始示例和我正在处理的项目是包括以下内容:

scene = mlab.gcf().scene
scene.renderer.set(use_depth_peeling=True)

我从这个关于类似问题的问题改编而来..

感谢马特和帕布的帮助。

我尝试了 depth_peeling,对于我的实际用例来说,它比这个 2 球体示例更有帮助。 但是与重新排列球体相比,边缘似乎更少......我认为抗锯齿可能是这个词?

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

image

对于我的 3d 绘图,我有一个点列表和一个颜色列表。 因此,我没有使用深度剥离,而是在绘图之前使用此函数将这些列表重新排序在一起:

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]

否则,排序调用可能就是所需的全部。 我从 python 文档中了解到这一点: https : ziphttps :

使用最近的 VTK 版本,这对我来说效果很好:

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

此外,您还可以使用f.scene.renderer.maximum_number_of_peels 。 默认情况下为 4,但您可以将其设置为零以表示没有限制,尽管这会减慢渲染速度。 你可以摆弄这个。

我可以关闭这个问题吗? 我认为这似乎确实解决了我以前见过的许多问题。

谢谢你。 我将能够处理这个问题。 你可以关闭这个问题。

马修·奥尔科克 | 博士研究员
谢菲尔德大学| 数学与统计学院
www.matthewallcock.co.uk

2018 年 8 月 26 日星期日,21:55 Prabhu Ramachandran, notifications@ github.com
写道:

使用最近的 VTK 版本,这对我来说效果很好:

从 mayavi 导入 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

此外,还有一个 f.scene.renderer.maximum_number_of_peels 你可以
潜在使用。 默认情况下为 4,但您可以将其设置为零表示不
限制,尽管这会减慢渲染速度。 你可以摆弄这个。

我可以关闭这个问题吗? 我认为这似乎确实解决了我遇到的许多问题
以前看过。


您收到此消息是因为您创作了该线程。
直接回复本邮件,在GitHub上查看
https://github.com/enthought/mayavi/issues/491#issuecomment-416071420
或静音线程
https://github.com/notifications/unsubscribe-auth/AP4RUC8AYAnDAV6-wE88hHw5cPP-x01gks5uUwtGgaJpZM4MT7Rp
.

万分感谢。

此页面是否有帮助?
0 / 5 - 0 等级

相关问题

rahulporuri picture rahulporuri  ·  3评论

Kekushke picture Kekushke  ·  9评论

relyativist picture relyativist  ·  16评论

yassersouri picture yassersouri  ·  5评论

anntzer picture anntzer  ·  7评论