Ask Your Question

Better rviz lighting control?

asked 2017-07-05 11:03:49 -0500

mogumbo gravatar image

updated 2017-07-05 11:29:54 -0500

lucasw gravatar image

Hi, I have set up a scene in RViz, but the lighting environment seems very limited. I can't find a way to add more lights, set an ambient light color for the scene, or specify ambient or specular values in materials. Is there a way to do any of these things or do I need to use something fancier like Gazebo? Any suggestions are welcome.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2017-07-05 11:42:38 -0500

lucasw gravatar image

updated 2017-07-05 11:47:29 -0500

Adding a light feature to rviz probably wouldn't be that hard- it is all Ogre3D underneath which supports multiple lights and controls easily. It would likely appear as an rviz display type like a Grid, but with light controls. Also there would need to be global options to disable the default light that is attached to the viewer camera.

Also I've been working off and on at a standalone gui-less ros renderer , it is very incomplete and has no interactivity through the display though: the user can set a tf transform of a light upstream of the bgfx node but instead of an interactive window it just publishes the rendered output on an Image topic. The idea is to make multiple lights possible (including casting shadows, which is currently supported for the one light), and all the parameters associated with the light will be exposed via services and/or dynamic reconfigure. It doesn't support many display types yet beyond triangle lists, but with some additional interest/motivation I'll get to it eventually.

For the short term gazebo probably is the best answer, head over to if it isn't clear from existing documentation how to set up lights there.

edit flag offensive delete link more



I think if you really need more realistic rendering, Gazebo or some other simulator is a better choice any way. RViz is really just meant as a data visualisation tool, not a (photo)realistic rendering. I would like RViz to be a little more up-to-date myself, but just so it looks nicer, nothing else.

gvdhoorn gravatar image gvdhoorn  ( 2017-07-05 11:55:51 -0500 )edit

Thanks for all the suggestions. That's the first I've heard of bgfx--now I want to learn more. I wouldn't say I'm going for photorealism, but you can convey a much better sense of 3D shapes with multiple lights and some specular highlights (shadows would be a big bonus).

mogumbo gravatar image mogumbo  ( 2017-07-05 12:10:40 -0500 )edit

Thinking further ahead, a good lighting simulation would be great for anyone prototyping robots that need to work in the dark or transmit images from dark environments.

mogumbo gravatar image mogumbo  ( 2017-07-05 12:12:37 -0500 )edit

There is also a Blender rendering option, I don't know the current best approach to that is. It would be great to have a node that translates rviz Markers to blender api, and to optionally make use of the Cycles renderer (at a very low frame rate, or non-real time), and render to ROS Image.

lucasw gravatar image lucasw  ( 2017-07-05 12:22:56 -0500 )edit

I'm not convinced yet bgfx is the best for what I'm trying to do- I have to borrow example shader code for rendering since it isn't provided internally, it is the opposite of the Ogre3D kitchen sink approach.

lucasw gravatar image lucasw  ( 2017-07-05 12:24:20 -0500 )edit

Just glancing at the API reference, it seems like bgfx only deals with a tiny amount of graphics state. I'd need to learn more, though. Was sort of wondering how you chose it over something like Ogre or OSG.

mogumbo gravatar image mogumbo  ( 2017-07-05 12:29:41 -0500 )edit

I've used both OSG and Ogre3D and wanted to try something new, different and smaller. I'd really like an open-source cross-platform real-time physically based renderer where light colors are defined by spectrums and just be able to say a material is wood or plastic or metal etc.

lucasw gravatar image lucasw  ( 2017-07-05 12:42:19 -0500 )edit

You and me and everyone else :) To do that in a general-purpose way you'll probably need a rendering engine that does automatic shader composition, a very tough problem to solve. And it could have really bad performance if done poorly.

mogumbo gravatar image mogumbo  ( 2017-07-05 12:55:58 -0500 )edit

answered 2017-07-07 16:39:56 -0500

mogumbo gravatar image

This is more of a discussion than an answer. I learned how to make Display plugins in RViz and made one called Light (wrapping Ogre::Light) and one called AmbientLight (wrapping Ogre::SceneManager::setAmbientLight). Right now Light is always an Ogre::Light::LT_DIRECTIONAL. I could probably make it changeable to a point light or spotlight, or make separate plugins for those. If I can get more time (working toward a deadline at the moment) I would also like to figure out how to attach the light to a frame and figure out how to disable the default light source attached to the RViz camera.

By default there is no ambient light in RViz, so viewing geometry from a non-default direction using a camera plugin reveals areas that are completely black. Adding AmbientLight fixes this, and adding extra Lights illuminates some shape in these areas.

After trying this I would probably never again make an RViz scene without these light plugins. If I have more time to fix things up, is this worth contributing to ROS for other people to use?

Adding ambient light has an interesting side-effect: hovering the mouse over an InteractiveMarker causes it to brighten. I believe I saw this "highlight" feature while browsing the code a couple weeks ago but didn't see a way to use it. Now it seems like it must be a feature that's fallen into disrepair without the presence of default ambient light.

I also see places in Rviz's robot_link.cpp and mesh_resource_marker.cpp where material ambient is set to the same color as material diffuse * 0.5. I would recommend removing the * 0.5 so that the full range of ambient light can be used, modulated only by the scene's ambient light value.


edit flag offensive delete link more



It would be fantastic if you could get this onto github. I can take a look at the frame attachment, though it should end up the same as every Marker since those are all attached to frames.

lucasw gravatar image lucasw  ( 2017-07-07 18:00:48 -0500 )edit

Okay, it's on github now. And I got frames working. Would love to see this get absorbed into RViz. But if not, maybe someone else will get some use out of it.

mogumbo gravatar image mogumbo  ( 2017-08-14 18:59:00 -0500 )edit

I'll try it out. You could also fork rviz instead of putting the diff in the readme of rviz_lighting, and then it would be easy to clone and perhaps merged into rviz proper.

lucasw gravatar image lucasw  ( 2017-08-15 21:56:38 -0500 )edit

I wouldn't want to hardcode stuff the way that I did in the diff. It just shows all the pieces I had to touch. To do it right I'd probably want to build some API around those things, but I'm not sure it's worth the effort unless RViz maintainers really want fancier lighting.

mogumbo gravatar image mogumbo  ( 2017-08-15 23:17:26 -0500 )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

1 follower


Asked: 2017-07-05 11:03:49 -0500

Seen: 1,072 times

Last updated: Jul 07 '17