如何降低Drake中MultiBodyPlant添加的几何体光泽度?
解决Drake中Meshcat显示物体过于光亮的问题
可以直接通过手动创建PhongIllustrationProperties对象来控制所有Phong材质参数,替代仅支持漫反射颜色的MakePhongIllustrationProperties便捷函数,具体实现如下:
C++ 示例代码
#include "drake/geometry/geometry_roles.h" // 创建自定义Phong材质属性 drake::geometry::PhongIllustrationProperties table_props; table_props.set_diffuse(table_color); // 保留原有漫反射颜色 table_props.set_ambient(Eigen::Vector3d(0.2, 0.2, 0.2)); // 环境光反射系数,按需调整 table_props.set_specular(Eigen::Vector3d(0.1, 0.1, 0.1)); // 降低高光反射强度,减少光泽感 table_props.set_shininess(5.0); // 高光指数,值越小高光越柔和,光泽度越低 // 注册视觉几何时传入自定义属性 plant.RegisterVisualGeometry( plant.world_body(), RigidTransform(p=table_position), table, "TableVisualGeometry", table_props);
Python 示例代码
from pydrake.geometry import PhongIllustrationProperties # 创建自定义Phong材质属性 table_props = PhongIllustrationProperties() table_props.set_diffuse(table_color) table_props.set_ambient([0.2, 0.2, 0.2]) table_props.set_specular([0.1, 0.1, 0.1]) table_props.set_shininess(5.0) # 注册视觉几何时传入自定义属性 plant.RegisterVisualGeometry( plant.world_body(), RigidTransform(p=table_position), table, "TableVisualGeometry", table_props)
参数调整说明
specular:控制高光反射的强度,值越小,高光越弱,物体整体光泽度越低;shininess:控制高光区域的大小和集中度,值越小,高光区域越宽且亮度越低,光泽感更柔和;ambient:控制环境光下的物体基础亮度,可按需微调整体明暗。
内容的提问来源于stack exchange,提问作者Mark
相关产品推荐
相关产品推荐

