Search code examples
drakephong

Drake geometry added using MultiBodyPlant is too shiny


I've added a "table" to my scene using Drake's MultiBodyPlant.

plant.RegisterVisualGeometry(
    plant.world_body(), RigidTransform(p=table_position),
    table, "TableVisualGeometry",
    table_color)

You can see it appears very shiny in meshcat.

shiny table

The documentation for RegisterVisualGeometry shows that I can specify an IllustrationProperty. This seems to be a simple key-value container, but I can't see what keys and values should be specified to control the meshcat representation. Elsewhere I found some reference to MakePhongIllustrationProperties, but it looks like the input is a diffuse color, with no way to control the actual Phong constants (specular, diffuse, and ambient reflection constants).

Is there a way to make my table less shiny?


Solution

  • Meshcat updated its three.js version in the last year. Three js moved their lighting model to a physically-based lighting model. This has implications for how you might want to articulate your model's appearance.

    1. Never use RGB values greater than 0.8.
    2. If you really care about the visual appearance, you might consider creating and referencing a glTF file. (Using a glTF will also actually change the kind of material that meshcat uses for the object, one that is a bit friendlier with the lighting model.)

    Furthermore, in meshcat, you might consider tweaking the lighting (reducing the intensity of the fill, ambient and point lights) to make it more compatible with how you specify your illustration geometries. MeshcatParams has the ability to set initial_properties where you can enumerate, for example, the initial light intensity values and/or shadows to control how your scene renders.

    We are currently in a rough transition where the specification of primitives and simple colors don't work as nicely as using glTF files. We'll probably be in the rough area for a while.