Depth Peeling

Depth Peeling#

深さのピーリングは,半透明のジオメトリを正しくレンダーするテクニックです.いくつかのオペレーティングシステムとVTKのバージョンはこのルーチンで問題があるので, pyvista.global_theme ではデフォルトで有効になっていません.

この例では,深度ピーリングによって得られる違いを示します. enable_depth_peeling() を参照してください.

from __future__ import annotations


import pyvista as pv
from pyvista import examples
centers = [(0, 0, 0), (1, 0, 0), (-1, 0, 0), (0, 1, 0), (0, -1, 0)]
radii = [1, 0.5, 0.5, 0.5, 0.5]

spheres = pv.MultiBlock()
for i, c in enumerate(centers):
    spheres.append(pv.Sphere(center=c, radius=radii[i]))
dargs = dict(opacity=0.5, color='red', smooth_shading=True)

pl = pv.Plotter(shape=(1, 2))

pl.add_mesh(spheres, **dargs)
pl.enable_depth_peeling(10)
pl.add_text('Depth Peeling')

pl.subplot(0, 1)
pl.add_text('Standard')
pl.add_mesh(spheres.copy(), **dargs)

pl.link_views()
pl.camera_position = pv.CameraPosition(
    position=(11.7, 4.7, -4.33), focal_point=(0.0, 0.0, 0.0), viewup=(0.3, 0.07, 0.9)
)
pl.show()
depth peeling

次の部屋のサーフェスの例では, Sam Potter によって提供されたメッシュは,トポロジが一致しており,グローバル不透明度値が使用されている場合に,深度レンダリングがこれらのジオメトリを正しくレンダリングするのに役立ちます.

room = examples.download_room_surface_mesh()

pl = pv.Plotter(shape=(1, 2))

pl.enable_depth_peeling(number_of_peels=4, occlusion_ratio=0)
pl.add_mesh(room, opacity=0.5, color='lightblue')
pl.add_text('Depth Peeling')

pl.subplot(0, 1)
pl.add_text('Standard')
pl.add_mesh(room.copy(), opacity=0.5, color='lightblue')

pl.link_views()
pl.camera_position = pv.CameraPosition(
    position=(43.6, 49.5, 19.8), focal_point=(0.0, 2.25, 0.0), viewup=(-0.57, 0.70, -0.42)
)

pl.show()
depth peeling

And here is another example when rendering many translucent contour surfaces.

mesh = examples.download_brain().resample(0.5, anti_aliasing=True)
contours = mesh.contour(5)
cmap = 'viridis_r'

pl = pv.Plotter(shape=(1, 2))

pl.add_mesh(contours, opacity=0.5, cmap=cmap)
pl.enable_depth_peeling(10)
pl.add_text('Depth Peeling')

pl.subplot(0, 1)
pl.add_text('Standard')
pl.add_mesh(contours.copy(), opacity=0.5, cmap=cmap)

pl.link_views()
pl.camera_position = pv.CameraPosition(
    position=(418.3, 659.0, 53.8),
    focal_point=(90.2, 111.5, 90.0),
    viewup=(0.03, 0.05, 1.0),
)
pl.show()
depth peeling

Tags: plot

Total running time of the script: (0 minutes 6.358 seconds)

Sphinx-Galleryによるギャラリー