isl-org / Open3D

Open3D: A Modern Library for 3D Data Processing
http://www.open3d.org
Other
11.21k stars 2.28k forks source link

How to remove the default room background from the visualizer? #4836

Open peterzxli opened 2 years ago

peterzxli commented 2 years ago

Checklist

My Question

Hi, how do I remove the default room background from the visualizer in python and C++? The room becomes visible on the surface of a reflective object.

Please refer to the example code and output below. Thanks!

import open3d as o3d
import open3d.visualization as vis
import numpy as np

sphere = o3d.geometry.TriangleMesh.create_sphere(1.0)
sphere.compute_vertex_normals()
sphere.translate(np.array([0, 0, 0]))
box = o3d.geometry.TriangleMesh.create_box(2, 4, 4)
box.translate(np.array([-1, -2, -2]))
box.compute_triangle_normals()

mat_sphere = vis.rendering.MaterialRecord()
mat_sphere.shader = 'defaultLit'
mat_sphere.base_color = [0.8, 0, 0, 1.0]

mat_box = vis.rendering.MaterialRecord()
mat_box.shader = 'defaultLitSSR'
mat_box.base_color = [0, 0, 0, 1.0] 
mat_box.base_roughness = 0.0
mat_box.base_reflectance = 1.0
mat_box.base_clearcoat = 0.0
mat_box.thickness = 4 
mat_box.transmission = 0.0
mat_box.absorption_distance = 1 
mat_box.absorption_color = [0, 1.0, 0] 
geoms = [{'name': 'sphere', 'geometry': sphere, 'material': mat_sphere},
         {'name': 'box', 'geometry': box, 'material': mat_box}]
vis.draw(geoms)

image

yxlao commented 2 years ago

Option 1

Try vis.draw(geoms, raw_mode=True) # Requires Open3D 0.15+

Option 2

Try vis.draw(geomes, show_skybox=False) # Requires Open3D 0.15+

Option 3

Turn it off from the GUI menu.

peterzxli commented 2 years ago

Thanks, but none of the options work. It seems that the room background is associated with the HDR map which can be turned off in the GUI. What API should I used to turn off the HDR map in C++?

yxlao commented 2 years ago

Thanks, but none of the options work.

Could you verify the Open3D version?

print(o3d.__version__)

Could you post a screenshot when you try Option 1?

errissa commented 2 years ago

Option 1 should have disabled the HDR map. Can you post a screenshot? Are you using 0.15?

In C++ you can use the EnableIndirectLighting of the Scene class to enable/disable HDR lighting.

peterzxli commented 2 years ago

Hi, I am on version 0.15.2. The visualizer crashes for option 1.

yxlao commented 2 years ago

@errissa Shall we also add this option (and other options) to the C++ open3d::visualization::Draw()?

yxlao commented 2 years ago

Ah, @peterzxli I think I now got what you mean. There are two things:

  1. The room that gets reflected by the mesh surface.
  2. The skybox (the blue thing in the background).

You want to remove 1. @errissa could probably help you with that.

peterzxli commented 2 years ago

@errissa I cannot find EnableIndirectLighting in open3d::visualization::rendering::Open3DScene class that I am using in C++. Can you please let me know how to achieve the same functionality in this class?

@yxlao Thanks for your help as well!

errissa commented 2 years ago

@peterzxli It’s a method of the low-level Scene class. You can get from the Open3DScene class with the GetScene method.

peterzxli commented 2 years ago

@errissa Thanks! On the C++ side, I am still seeing some undesirable gradient in the background if the box is viewed at a certain perspective. I use the following visualization setting and see the following results:

Can you please let me know how to resolve this? Thanks again!

mat.shader = "defaultLitSSR";
mat.base_color << 0, 0, 0, 1;
mat.base_roughness = 0.0;
mat.base_reflectance = 0.0;
mat.base_clearcoat = 0.0;
mat.thickness = 4;
mat.transmission = 0.8;
mat.absorption_distance = 1;
mat.absorption_color << 0, 1, 0;
auto test_box = open3d::geometry::TriangleMesh::CreateBox(5,5,5);
this->widget3d_->GetScene()->AddGeometry("bbox", test_box.get(), mat);
this->widget3d_->GetScene()->GetScene()->EnableIndirectLight(false);
this->widget3d_->GetScene()->ShowSkybox(false);

Desirable result (when viewed at some perspectives): image

Undesirable result (when viewed at some other perspectives): image

errissa commented 2 years ago

@peterzxli I will look into this but this looks like it could be the correct behavior given the material settings. In the meantime, if you haven't already please review the Filament material guide to make sure you're setting the material properties correctly for your desired result.

peterzxli commented 2 years ago

This behavior only appears in C++ (not python). It looks like there is a ground plane with a darker color hidden in the background. I turned the ground plane off though.