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

Extend ShaderParam system to support loading different shader languages #1335

Merged
merged 26 commits into from
Mar 1, 2022

Conversation

iche033
Copy link
Contributor

@iche033 iche033 commented Feb 12, 2022

🎉 New feature

Summary

Implemented proposed idea from: #1275 (comment)

The idea is to let users specify different shader files to use. The <shader> sdf element now takes an optional language attribute. On macOS, the system will use metal shaders over glsl if specified.

The deformable_sphere and waves models on Fuel have been updated to include metal shaders.

Test it

Remove the deformable_sphere and waves models in your fuel cache (~/.ignition/fuel/fuel.ignitionrobotics.org/openrobotics/models/) then run ign-gazebo with shaders_param.sdf world. You should get the same output as the screenshot shown in #1310

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.

@iche033 iche033 requested a review from chapulina as a code owner February 12, 2022 00:31
@github-actions github-actions bot added the 🏯 fortress Ignition Fortress label Feb 12, 2022
@iche033
Copy link
Contributor Author

iche033 commented Feb 12, 2022

@srmainwaring, I integrated your shaders into the existing models. Hope I didn't mess anything up.

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

codecov bot commented Feb 12, 2022

Codecov Report

Merging #1335 (fc02517) into ign-gazebo6 (e0d88f7) will increase coverage by 0.06%.
The diff coverage is 100.00%.

❗ Current head fc02517 differs from pull request most recent head 95b1817. Consider uploading reports for the commit 95b1817 to get more accurate results

Impacted file tree graph

@@               Coverage Diff               @@
##           ign-gazebo6    #1335      +/-   ##
===============================================
+ Coverage        62.91%   62.97%   +0.06%     
===============================================
  Files              299      301       +2     
  Lines            24151    24208      +57     
===============================================
+ Hits             15194    15245      +51     
- Misses            8957     8963       +6     
Impacted Files Coverage Δ
include/ignition/gazebo/Link.hh 100.00% <ø> (ø)
src/SimulationRunner.hh 100.00% <ø> (ø)
src/systems/physics/Physics.hh 100.00% <ø> (ø)
src/systems/pose_publisher/PosePublisher.hh 100.00% <ø> (ø)
src/Link.cc 94.77% <100.00%> (+0.28%) ⬆️
src/SimulationRunner.cc 91.12% <100.00%> (-1.26%) ⬇️
src/SystemInternal.hh 100.00% <100.00%> (ø)
src/SystemManager.cc 100.00% <100.00%> (ø)
src/systems/lift_drag/LiftDrag.cc 62.85% <100.00%> (ø)
src/systems/physics/Physics.cc 71.75% <100.00%> (+0.19%) ⬆️
... 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 1e31b53...95b1817. Read the comment docs.

@srmainwaring
Copy link
Contributor

I integrated your shaders into the existing models. Hope I didn't mess anything up.

Thanks @iche033! - I'm sure you haven't. I'll give them a test and let you know.

Working on porting my more general wave model to Ignition at present - not quite straightforward as it updates the Ogre::v1::Mesh and that route is no longer available. I looked at the Ogre2DynamicRenderable but don't think it quite does what I need - also no support for tangent vectors which are needed for bump mapping. I'm looking at the Ogre2 DynamicGeometry example with a view to using the approach suggested there.

A couple of things I noticed when trying to map shader materials onto a custom mesh:

  • the ShaderParams doesn't seem to supply the normals to the vertex shader (just the positions and uv0 texture coords). I can add a VES_NORMAL param to the inputs but it is zeroed.
  • it doesn't look like you can use the material defined by ShaderParams in another system plugin declared in the same visual.

I'll post an issue with some simplified examples to illustrate.

Copy link
Contributor

@nkoenig nkoenig left a comment

Choose a reason for hiding this comment

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

Looks good to me. Not sure if srmainwaring has additional comments.

@iche033
Copy link
Contributor Author

iche033 commented Feb 24, 2022

@srmainwaring oops I missed your comment

  • the ShaderParams doesn't seem to supply the normals to the vertex shader (just the positions and uv0 texture coords). I can add a VES_NORMAL param to the inputs but it is zeroed.

yep that sounds good to me.

  • it doesn't look like you can use the material defined by ShaderParams in another system plugin declared in the same visual.

hmm like the entire ogre material or specific texture? I would have expected ogre to add the texture to its resource path so that it would be available to others but that also depends on the order in which the systems are loaded.

@srmainwaring
Copy link
Contributor

it doesn't look like you can use the material defined by ShaderParams in another system plugin declared in the same visual.

On this second point it turns out that only one plugin per visual is processed at present, and that is which ever one is declared last is loaded and the preceding ones are ignored. The protobuf Visual message allows for multiple plugins, but the server dispatching the message does not, and there may also be an assumption of one plugin on the GUI side as well.

I can work around this for the moment by replicating the ShaderParam plugin logic in my plugin, so it's probably best to submit support for multiple plugins as a feature request.

On the first point, addition of normals and tangent attributes, I have some more work to get that working for my example, so again that would best be included as a follow up.

@iche033
Copy link
Contributor Author

iche033 commented Feb 24, 2022

On this second point it turns out that only one plugin per visual is processed at present, and that is which ever one is declared last is loaded and the preceding ones are ignored. The protobuf Visual message allows for multiple plugins, but the server dispatching the message does not, and there may also be an assumption of one plugin on the GUI side as well.

ok you're right. I've ticketed an issue for this. #1363

@iche033
Copy link
Contributor Author

iche033 commented Mar 1, 2022

I'll merge this first. We can address other issues as they come up.

@iche033 iche033 merged commit 6d17cc1 into ign-gazebo6 Mar 1, 2022
@iche033 iche033 deleted the shader_param_metal branch March 1, 2022 01:11
@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-25-fortress-edifice-citadel/1343/1

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.

4 participants