Search code examples
c++shadervisualizationgraph-visualizationopen3d

How to Render Transparent Surface in Open3D with C++


I want to render several translucent surfaces. However, I've found that I can't use the RGBA format directly.

I attempted to use shaders, and consulted the official docs, only found a few classes and methods without any tutorial or examples (like open3d::visualization::rendering::Material, open3d::visualization::rendering::MaterialRecord, open3d::visualization::rendering::Renderer ...)

A protected member of open3d::visualization::Visualizer, std::unordered_set< std::shared_ptr< glsl::GeometryRenderer >> geometry_renderer_ptrs_, looks like what I want, though I can't find any methods to access it indirectly.

I also checked the github issues: https://github.com/isl-org/Open3D/issues/2890, but not helpful for me.

Things in python seems much simpler,

import open3d as o3d

plane = o3d.geometry.TriangleMesh.create_box(5,0.1,2, create_uv_map=True, map_texture_to_each_face=True)
plane.compute_triangle_normals()
mat = o3d.visualization.rendering.MaterialRecord()
mat.shader = "defaultLitTransparency"
mat.albedo_img = o3d.io.read_image("../test_scripts/google_street.png")

o3d.visualization.draw({'name': 'plane', 'geometry': plane, 'material': mat})

I want to know how I can achieve the same effect as this. If possible, I would like to know how to use custom shaders with Geometries in Open3D in C++. (I really need some examples)

environment : open3d-devel-windows-amd64-0.18.0 binary library


Solution

  • After 2 days I found the answer. Open3D for C++ does not provide translucent methods. I inherit the original Visualizer class and Renderer class, overwrite original shaders with my own.

    the result