Gazebo | Ignition | Community
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How do I get my OBJ mesh material to look right?

I have a "rock" object in an OBJ file that has many triangular faces, and has an accompanying MTL file with different shades of gray for the Ka, Kd, and Ks:

newmtl RockCol
Ka 0.1 0.1 0.1
Kd 0.4 0.4 0.4
Ks 0.7 0.7 0.7
Ns 300
Ni 1.0
d 1.0
illum 0

In Paint 3D, for example, it looks like this:

image description

In Gazebo (11.10.2), I've tried a bunch of different things to get it to display the faces/colors correctly, but no matter what I try, the rock always displays as one solid color, so you can't tell it has multiple faces (default gray box is included for reference):

image description

It does change color when the angle changes, as if it knows there are other shades of gray associated with ambient/diffuse/specular, but at any given angle, it's a solid color--here it is looking slightly lighter gray when turned:

image description

Some things I've tried:

Referencing the .mtl file directly:

<visual name='visual'>
  <pose>0 0 0 0 -0 0</pose>
  <geometry>
    <mesh>
      <uri>/home/MyName/Documents/ObjectFiles/rock_x2y3_1.obj</uri>
      <scale>1 1 1</scale>
    </mesh>
  </geometry>
  <material>
    <lighting>1</lighting>
    <script>
      <uri>file:/home/MyName/Documents/ObjectFiles/RockColor.mtl</uri>
      <name>RockGray</name>
    </script>
    <shader type='pixel'/>
  </material>
  <transparency>0</transparency>
  <cast_shadows>1</cast_shadows>
</visual>

Putting nothing in <material></material> and hoping it finds the .mtl file as referenced in the .obj file (keeping the rest of the <visual></visual> section the same as above).

Referencing the same script that is used for the default box:

  <material>
    <lighting>1</lighting>
    <script>
      <uri>file://media/materials/scripts/gazebo.material</uri>
      <name>Gazebo/Grey</name>
    </script>
    <shader type='pixel'/>
  </material>

Specifying the colors in the sdf:

  <material>
    <lighting>1</lighting>
    <script>
      <uri>file://media/materials/scripts/gazebo.material</uri>
      <name>Gazebo/Grey</name>
    </script>
    <shader type='pixel'>
      <normal_map>__default__</normal_map>
    </shader>
    <ambient>0.1 0.1 0.1 1.0</ambient>
    <diffuse>0.4 0.4 0.4 1.0</diffuse>
    <specular>0.7 0.7 0.7 1.0</specular>
    <emissive>0 0 0 1</emissive>
  </material>

I'm new to this, and at this point am just stabbing in the dark. Maybe the problem isn't the material section, but something else entirely. Maybe it's just one line in the <visual> section that I've ignored and needs changing. Maybe what I'm trying to do just can't be done with OBJ meshes, or in Gazebo 11. I haven't found a lot of info on all the options of how to set up the appearance of things from OBJ files, so any pointers for things to try would be welcome. Thanks!