Ask Your Question
2

Smooth Shading for environments in gazebo

asked 2012-01-26 04:33:25 -0600

updated 2012-01-26 22:17:50 -0600

Is it possible to activate smooth shading for parts of the world in gazebo? For natural environments like rolling hills, smooth shading (e.g. gouraud) looks a lot better than the default flat shading. I'd like to have something like this (example using meshlab):

image description

instead of this:

image description

The image in gazebo is done using this material:

material Hector/Gouraud
{
  receive_shadows on
  shading gouraud

  technique
  {
    pass Ambient
    {
      ambient 1.000000 1.000000 1.000000 1.000000
      diffuse 1.0 1.0 1.0 1.0
      specular 0.8 0.8 0.8 1 20
      shading gouraud
    }

    pass PointLight
    {
      ambient 1.000000 1.000000 1.000000 1.000000
      diffuse 1.0 1.0 1.0 1.0
      specular 0.8 0.8 0.8 1 20
      shading gouraud
    }
  }
}

used like this in the world file:

   <model:physical name="landscape">
   <xyz>0 0 0</xyz> 
   <rpy>0 0 0</rpy>
   <static>true</static>
   <body:trimesh name="landscape_body">
     <geom:trimesh name="landscape_geom">
       <scale>1.0 1.0 1.0</scale>
       <mesh>rolling_landscape_blender_export_meshlab_resave.dae</mesh>
       <genTexCoord>true</genTexCoord>
       <visual>
         <scale>1.0 1.0 1.0</scale>
         <mesh>rolling_landscape_blender_export_meshlab_resave.dae</mesh>

     <!--<material>Hector/BlueBrushedAluminum</material>-->
         <material>Hector/Gouraud</material>
       </visual>
     </geom:trimesh>
   </body:trimesh>
  </model:physical>

Unfortunately, the material system has no detailed documentation that I'm aware of, so I don't know exactly what I have to do differently. The example is available in the hector_gazebo_worlds package and can be started using

roslaunch hector_gazebo_worlds rolling_landscape_120m.launch
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2012-01-28 06:44:28 -0600

updated 2012-01-28 08:03:34 -0600

I found out an option for achieving smooth shading inside gazebo: Using Blender, "smooth shading" can be selected for all areas of your model that should be smooth shaded (I thought this was only a visualization option, but it in fact actually is a property of the mesh). Blender materials can also be used to set the color and lighting properties of the model. Then, after converting the model to triangles only (to work around gazebo not working with quad based COLLADA, as described here), the model can be exported to a .dae COLLADA model. When not specifying a material in the world file using the <material> tag, the materials of the .dae will be used.

Example image:

image description

/edit: Confirmation that textures work, too:

image description

edit flag offensive delete link more

Comments

1

Have you noticed that the hector_gazebo_worlds rolling landscape mesh is rendered incorrectly in recently distributed Gazebo debs (1.9.6 and 4.0.2)? Running the dae through meshlab fixes the rendering issue but it is no longer smooth.

mboulet gravatar imagemboulet ( 2014-10-09 09:49:05 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2012-01-26 04:33:25 -0600

Seen: 780 times

Last updated: Jan 28 '12