Transparency channel for point cloud for Open3D
Asked Answered
S

1

9

Is there a way in Open3D (Python) to set the transparency channel for a given point cloud ? I have searched for quite a long time and was not able to find anything. I found a discussion on the project's Github which hints that this is possible but I could not find any example.

Would anyone have some kind of idea on how to do it?

Shatter answered 7/10, 2021 at 9:29 Comment(0)
J
0

Open3D visualizer open3d.visualization.O3DVisualizer uses Filament which supports setting transparency to the rendered materials.

The sample code below defines transparent material for rendering of the pointcloud.

import numpy as np
import open3d as o3d

# Create three random point clouds
rng = np.random.default_rng()
pts1 = rng.random((100, 3), dtype=np.float32)
pts2 = rng.random((100, 3), dtype=np.float32)
pts3 = rng.random((100, 3), dtype=np.float32)
t1 = o3d.core.Tensor(pts1)
t2 = o3d.core.Tensor(pts2)
t3 = o3d.core.Tensor(pts3)
pcd1 = o3d.t.geometry.PointCloud(t1)
pcd2 = o3d.t.geometry.PointCloud(t2)
pcd3 = o3d.t.geometry.PointCloud(t3)

mat1 = o3d.visualization.rendering.MaterialRecord()
mat1.shader = 'defaultLitTransparency'
mat1.base_color = [1.0, 0.0, 0.0, 0.5]  # RGBA, adjust A for transparency
mat1.point_size = 20.0
mat2 = o3d.visualization.rendering.MaterialRecord()
mat2.shader = 'defaultLitTransparency'
mat2.base_color = [0.0, 1.0, 0.0, 0.3]  # RGBA, adjust A for transparency
mat2.point_size = 20.0
mat3 = o3d.visualization.rendering.MaterialRecord()
mat3.shader = 'defaultLitTransparency'
mat3.base_color = [0.0, 0.0, 1.0, 0.1]  # RGBA, adjust A for transparency
mat3.point_size = 20.0

clouds = [{'name': 'pcd1', 'geometry': pcd1, 'material': mat1},
          {'name': 'pcd2', 'geometry': pcd2, 'material': mat2},
          {'name': 'pcd3', 'geometry': pcd3, 'material': mat3}]

# o3d.visualization.draw uses open3d.visualization.O3DVisualizer to display the geometries
o3d.visualization.draw(clouds, bg_color=(0.1, 0.1, 0.1, 1.0), show_skybox=False)

For more options, please check MaterialRecord and the Filament guide.

References - Above code is from https://github.com/isl-org/Open3D/issues/3735, with minor modifications to the point size and alpha.

Jehoshaphat answered 8/4 at 12:59 Comment(1)
If new to PBR, also see creativecloud.adobe.com/cc/learn/substance-3d-designer/web/…Jehoshaphat

© 2022 - 2024 — McMap. All rights reserved.