-
-
Notifications
You must be signed in to change notification settings - Fork 467
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding flexibility to the lighting environment #1146
Conversation
Thanks, we'll have a look when we have time. This looks useful, but anything that touches the material type or lighting is notoriously time consuming to acceptance test in rviz. So please be patient as it might be a while before we have time to review it. |
Thanks for looking at it. I think the change to ambient material properties is sensible. However, we could go a little further and control specular material with more global properties. The properties could default to a specular value of {0,0,0}, which would be zero impact to current users. Or maybe specular can be optionally specified wherever the diffuse color gets specified. |
It would be nice if the headlight had a color control. Though it starts to get redundant with rviz_lighting: instead of a special case global option for a head light it would be nice if there was an rviz_lighting light attached to the rviz camera that is on by default (requiring rviz_lighting get merged in here), which suggests that the rviz camera generate a tf frame to hang off of (which might be useful elsewhere), but it would be annoying to have the tf rviz plugin to draw the tf visuals pointing right into the camera so it could have a special case not to draw it. The additional benefit is that the headlight could be a spotlight or a point light. |
Agreed. Using the same light code everywhere would be straightforward. Before absorbing something like rviz_lighting, it might be worth considering if any features should be added first, such as shadows or the ability to specify lights in a URDF (if a light is going to be attached to a robot's frame, it makes a lot of sense to specify it with the rest of the robot). |
Just curious if there has been any progress on this pull request? I need to get started working with rviz and multiple lights again. I'll just keep using a fork of rviz for now if necessary. |
nothing at this stage @mogumbo; we appreciate your patience in the meantime |
OK @mogumbo, I've taken a look. I'll comment on the different changes separately. On the ability to toggle the default light: I think it's fine to add a toggle to the global options to support users adding custom Light displays. I don't think we should add the ability to modify the default light source because for most users this is not needed, and in cases where the default light source isn't appropriate then custom lights can be used instead. Whether those lights are fixed or attached to the rviz view is a separate question (though if users are looking to represent lighting of an environment more realistically, then perhaps just fixed lights would be sufficient). I have some comments about the wording used but otherwise the changes related to this look good. Since we aren't adding a new default display we won't have to update Regarding the changes to default material properties:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these comments are only for changes from d6dab41
src/rviz/visualization_manager.cpp
Outdated
@@ -178,6 +178,10 @@ VisualizationManager::VisualizationManager( RenderPanel* render_panel, WindowMan | |||
"RViz will try to render this many frames per second.", | |||
global_options_, SLOT( updateFps() ), this ); | |||
|
|||
headlight_property_ = new BoolProperty( "Headlight", true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest to name this "Default Light" (headlight makes less sense when considering a large-scale visualisation, and suggests it's a spotlight). Unless @wjwwood you have another suggestion for what to call the global directional light?
src/rviz/visualization_manager.cpp
Outdated
@@ -178,6 +178,10 @@ VisualizationManager::VisualizationManager( RenderPanel* render_panel, WindowMan | |||
"RViz will try to render this many frames per second.", | |||
global_options_, SLOT( updateFps() ), this ); | |||
|
|||
headlight_property_ = new BoolProperty( "Headlight", true, | |||
"Default light source attached to camera.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The use of camera here can be confused with the Camera display type; I'd suggest "Light source attached to the current 3D view."
src/rviz/visualization_manager.cpp
Outdated
@@ -518,6 +524,11 @@ void VisualizationManager::updateFps() | |||
} | |||
} | |||
|
|||
void VisualizationManager::updateHeadlight() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make it clearer that this is a toggle, it would be appropriate to name the property default_light_enabled_property_
and rename the function to updateDefaultLightVisible
, similar to:
robot_->setCollisionVisible( collision_enabled_property_->getValue().toBool() ); |
@dhood, thank you for looking at this. I'll make the changes you requested, and then hopefully it can be merged. I'm glad you can accept a toggle for the default light since that's the most important change I made.
(Out of curiosity, why was the ambient material value set at all if there was no ambient light in RViz? Was there ambient light in the past that got removed at some point?)
|
When you do so, please push additional commits with the changes/removing previous changes (it's easier for reviewing than force-pushing amended commits) and then we will squash-and-merge at the end. RE ambient light, your points might be valid in a conceptual sense, but we have to work within the technical range of Ogre: FWIU ambient light values represent the minimum lighting of a material, and specular/diffuse effects are added to that value with the final result being clamped to (0,1) range. This is why we want to reduce the ambient component, to reduce the chance of clipping when all light effects are summed. If we don't scale it down, then a white sphere with white ambient light cannot show the diffuse effects: I've also recently noticed that this "washed out" effect has been referenced in #841 (comment) when meshes didn't have their ambient colour scaled. So I maintain that the scaling should be left as it was.
Not that I am aware of, but it seems common practice to scale the ambient light back when adding diffuse properties of a material (because of what I mentioned above) so my guess is that it was "just in case". I can't answer with certainty because I wasn't involved in the project at the time.
Since it's not possible to define it for URDF-specified materials, rather than be a "default" this would instead essentially be a global property of all URDF-defined materials, and I am of the opinion that a global property does not make sense for this since material properties should be specified for each material individually. Having come across #841, another reason to not set the light properties to an rviz-specified value is that other applications like gazebo won't use the same light properties. (Additionally, as I mentioned earlier, this value would be different to the defaults used for .stl meshes and that for .dae meshes, even within rviz). So, while I can appreciate that it's frustrating to not be able to change the light properties of materials specified in URDF, I don't think we can accept the changes to the specular/shininess properties. For your testing of rviz_lighting you will be able to use collada meshes that allow you to specify light properties of materials. If you really want to use URDF-defined materials with custom light properties, you can consider proposing support for that in the URDF specification, and then rviz could be updated to reflect the values. |
Changes pushed. Thanks for your help. The screenshots in #841 imply there was ambient lighting in rviz in 2015. I wonder what happened to it. So the minimum lighting you'll see on an object is the material_ambient * light_ambient. You can keep colors from saturating by doing something like material_ambient = 0.2 and material_diffuse = 0.8. But this only works if you have one light in your scene. Once you have two or more lights, their contributions can still add to more than one. So the way you usually prevent saturation is by trying to keep light contributions under control. And in practice you would never set light_ambient = 1.0. But if you want to keep lighting consistent with gazebo like in #841 then that's a whole other ball of string :P |
You're right that this current approach won't completely prevent saturation, especially if users can add their own lights.
Yeah I was thinking the same thing... an investigation for another day 😄 Thanks for iterating @mogumbo |
@dhood Unfortunately this PR broke ABI compatibility by introducing a new variable to |
@rhaschke thanks for pointing this out; that was an oversight on my part. I'll look at adding an automated abi checker to avoid it happening again. |
These changes make it so lights other than RViz's default headlight can be used, such as the ones you find in a plugin like https://github.com/mogumbo/rviz_lighting. The default headlight can now be switched on or off using a global property.
I also changed the default material properties so that specular light from light sources can be seen and so that the full range of ambient light can be seen instead of only half of it. As far as I can tell, there is currently no ambient or specular light coming from light sources in RViz (users would need to be getting that from plugins), so this change should be low-impact.