Skip to content
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

Load and run visual plugin (system) on GUI side #1275

Merged
merged 14 commits into from
Feb 4, 2022
Merged

Conversation

iche033
Copy link
Contributor

@iche033 iche033 commented Jan 8, 2022

🎉 New feature

Related PR: gazebosim/gz-rendering#533 - Needed for running the shader_param.sdf demo world added in this PR, and also for shader_param_system integration test to pass.

Summary

This PR allows visual plugins to be loaded on the gui side.

Changes include:

  • adding a VisualPlugin component to store the <plugin> sdf element
    • this component is sent from server to gui
  • adding a VisualPlugin gui event for GzSceneManager to notify GuiRunner that a new visual plugin is detected
  • extending GuiRunner to load and run systems (visual plugin)
    • this can probably be refactored later to avoid duplicate code with SimulationRunner
  • adding a SceneUpdate event that systems can connect to on both the server and gui side for rendering
  • adding a ShaderParam visual plugin (ported from gazebo-classic) to test the whole pipeline

Test it

Run the shader_param.sdf world - this world contains a sphere model with the new ShaderParam system that modifies its appearance using custom shaders. Requires gazebosim/gz-rendering#533

ign gazebo -v 4  -r shader_param.sdf

shader_param

Checklist

  • Signed all commits for DCO
  • Added tests
  • Added example and/or tutorial
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by messages.

Comment on lines 21 to 22
#include <sdf/Element.hh>
#include <sdf/parser.hh>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alphabetize

Copy link
Contributor Author

@iche033 iche033 Jan 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm I think this means alphabetize and also take into account case-sensitivity? If so, done in 9f4a753

include/ignition/gazebo/components/Visual.hh Outdated Show resolved Hide resolved
include/ignition/gazebo/components/Visual.hh Show resolved Hide resolved
include/ignition/gazebo/gui/GuiEvents.hh Outdated Show resolved Hide resolved
include/ignition/gazebo/gui/GuiEvents.hh Outdated Show resolved Hide resolved
#include <set>

#include "../../GuiRunner.hh"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it fine to add relative paths ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src/systems/shader_param/ShaderParam.cc Outdated Show resolved Hide resolved
test/integration/shader_param_system.cc Outdated Show resolved Hide resolved
test/integration/shader_param_system.cc Outdated Show resolved Hide resolved
test/plugins/TestVisualSystem.hh Outdated Show resolved Hide resolved
@chapulina chapulina added the needs upstream release Blocked by a release of an upstream library label Jan 10, 2022
@chapulina
Copy link
Contributor

chapulina commented Jan 10, 2022

I believe this closes #657 and #265

@codecov
Copy link

codecov bot commented Jan 21, 2022

Codecov Report

Merging #1275 (0dead05) into ign-gazebo6 (912e2ce) will decrease coverage by 0.19%.
The diff coverage is 26.27%.

Impacted file tree graph

@@               Coverage Diff               @@
##           ign-gazebo6    #1275      +/-   ##
===============================================
- Coverage        62.25%   62.06%   -0.20%     
===============================================
  Files              278      278              
  Lines            23203    23315     +112     
===============================================
+ Hits             14445    14470      +25     
- Misses            8758     8845      +87     
Impacted Files Coverage Δ
include/ignition/gazebo/gui/GuiEvents.hh 0.00% <ø> (ø)
include/ignition/gazebo/rendering/RenderUtil.hh 100.00% <ø> (ø)
src/SimulationRunner.hh 100.00% <ø> (ø)
src/gui/GuiEvents.cc 44.44% <0.00%> (-12.70%) ⬇️
src/gui/GuiRunner.hh 100.00% <ø> (ø)
src/gui/plugins/scene_manager/GzSceneManager.cc 19.17% <0.00%> (-8.28%) ⬇️
include/ignition/gazebo/components/Visual.hh 12.50% <6.66%> (-87.50%) ⬇️
src/gui/GuiRunner.cc 51.03% <30.50%> (-16.00%) ⬇️
src/SdfEntityCreator.cc 85.51% <100.00%> (+0.17%) ⬆️
src/rendering/RenderUtil.cc 36.53% <100.00%> (+0.20%) ⬆️
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 912e2ce...0dead05. Read the comment docs.

@iche033 iche033 removed the needs upstream release Blocked by a release of an upstream library label Jan 29, 2022
Copy link
Contributor

@ahcorde ahcorde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just some minor style issues

src/gui/GuiRunner.cc Show resolved Hide resolved
src/systems/shader_param/ShaderParam.cc Outdated Show resolved Hide resolved
Signed-off-by: Ian Chen <[email protected]>
@iche033 iche033 merged commit 717a7e9 into ign-gazebo6 Feb 4, 2022
@iche033 iche033 deleted the visual_plugin branch February 4, 2022 01:40
@srmainwaring
Copy link
Contributor

srmainwaring commented Feb 7, 2022

@iche033 - just checked and that this works for Metal with gazebosim/gz-rendering#554 🙂

visual_plugin

Here are the metal shaders:

deform_fs.metal.zip
deform_vs.metal.zip

This commit adds textures: srmainwaring@66a8490, then we can run the waves example

waves-gazebo.mov

ocean_waves.sdf.zip
ocean_waves.zip

srmainwaring pushed a commit to srmainwaring/gz-sim that referenced this pull request Feb 8, 2022
* load and run visual plugins on gui end

Signed-off-by: Ian Chen <[email protected]>

* scene update event emitted on both server and gui side

Signed-off-by: Ian Chen <[email protected]>

* shader param update working

Signed-off-by: Ian Chen <[email protected]>

* sim time, constants, full example working

Signed-off-by: Ian Chen <[email protected]>

* add integration test

Signed-off-by: Ian Chen <[email protected]>

* code cleanup

Signed-off-by: Ian Chen <[email protected]>

* more code cleanup

Signed-off-by: Ian Chen <[email protected]>

* style fixes and add some comments

Signed-off-by: Ian Chen <[email protected]>

* review changes

Signed-off-by: Ian Chen <[email protected]>

* require display for shader param test

Signed-off-by: Ian Chen <[email protected]>

* style and comment

Signed-off-by: Ian Chen <[email protected]>
@iche033
Copy link
Contributor Author

iche033 commented Feb 8, 2022

oh nice, looks like you forward ported this to Garden? I can update the shader param system to read metal shaders, e.g. something like:

<shader launguage="glsl">
  <vertex>path_to_vertex_shader.glsl</vertex>
  <fragment>path_to_fragment_shader.glsl</fragment>
</shader> 
<shader launguage="metal">
  <vertex>path_to_vertex_shader.metal</vertex>
  <fragment>path_to_fragment_shader.metal</fragment>
</shader> 

This just lets user specify multiple shader files and the system will then select the best shader to use depending on the platform. How does that look?

@iche033
Copy link
Contributor Author

iche033 commented Feb 8, 2022

Implemented the above idea in the shader_param_metal branch. I'll create a PR once I can upload metal shaders to Fuel.

I've also created gazebosim/gz-rendering#558 to accomodate cases like gazebosim/gz-rendering#554 where extra params (shader_reflection_pair_hint) are needed for metal but not glsl

@srmainwaring
Copy link
Contributor

srmainwaring commented Feb 8, 2022

oh nice, looks like you forward ported this to Garden?

Yes, just cherry-picked it in. Most of the Metal support needs Garden now because of various ABI breaking interface changes. Did you want me to post a PR for the texture add-on or will you pull the commit into the shader_param_metal branch? Either way is good for me.

Your proposed changes for multi-shader language support and extra param checks look good!

Appreciate everyone is super busy, would you mind asking the other reviewers for the Metal GUI PR if they could take a look? It would be nice to get it merged while it's passing CI clean and before it needs a rebase.

@srmainwaring
Copy link
Contributor

@iche033 Just noticed you've already done all the texture changes in #1310! I should have looked more carefully...

@osrf-triage
Copy link

This pull request has been mentioned on Gazebo Community. There might be relevant details there:

https://community.gazebosim.org/t/new-ignition-releases-2022-03-01-citadel-edifice-fortress/1313/1

@osrf-triage
Copy link

This pull request has been mentioned on Gazebo Community. There might be relevant details there:

https://community.gazebosim.org/t/using-a-custom-hlms-with-ignition-rendering/1315/2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏯 fortress Ignition Fortress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants