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

Parse MaterialX metadata into SdrProperty #1895

Conversation

seando-adsk
Copy link
Contributor

Description of Change(s)

Fixes #1874

  • "enum" and "enumvalues" are parsed as options
  • "doc" is parsed as help
  • "uiname" is parsed as label
  • "uifolder" is parsed as page
  • all other MaterialX metadata is added as hints
  • I have submitted a signed Contributor License Agreement

Fixes PixarAnimationStudios#1874

- "enum" and "enumvalues" are parsed as options
- "doc" is parsed as help
- "uiname" is parsed as label
- "uifolder" is parsed as page
- all other MaterialX metadata is added as hints
@jilliene
Copy link

jilliene commented Jun 7, 2022

Filed as internal issue #USD-7414

if (!isOutput && primvars != nullptr) {

// If an input has "defaultgeomprop", that means it reads from the
// primvar specified unless connected. We mark these in Sdr as
// always-required primvars; note that this means we might overestimate
// which primvars are referenced in a material.
const auto& defaultgeomprop = element->getAttribute(defaultgeompropName);
const auto& defaultgeomprop = element->getAttribute(_tokens->defaultgeomprop.GetString());
Copy link
Member

Choose a reason for hiding this comment

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

TfToken should auto-convert to std::string

Comment on lines 331 to 333
ParseMetadata(metadata, SdrPropertyMetadata->Label, element, "uiname");
ParseMetadata(metadata, SdrPropertyMetadata->Help, element, "doc");
ParseMetadata(metadata, SdrPropertyMetadata->Page, element, "uifolder");
Copy link
Member

Choose a reason for hiding this comment

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

Any reason why these three literals, plus "enum" and "enumvalues" above aren't also added to the private tokens?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, but not necessarily a good one. These strings are only used as std::string on the MaterialX side of things. Would be best to have them as tokens as well since that prevents an unnecessary malloc/strcpy.


if (!metadata.count(SdrPropertyMetadata->Help) &&
metadata.count(_tokens->unit)) {
// The unit can be helpful if there is no documentation.
Copy link
Member

Choose a reason for hiding this comment

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

Not sure what unittype is, but would it also be useful? Seems like defaultgeomprop would also be handy to provide?

Copy link
Contributor

Choose a reason for hiding this comment

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

I see only two places in MaterialX where unittype is defined. There are a few angles defined as being "unittype = radian" and one thin_film thickness being tagged with "unittype = nanometer". I suspect ST coordinates could be in meters in some future, but we are not there yet.

Copy link
Member

Choose a reason for hiding this comment

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

Oh hmmm... these will want to be very prominently documented, as they diverge from USD norms. All angles are degrees in USD schemas, and linear units are generally relative to stage metersPerUnit . So yeah, I'd double-down on wanting to fold unittype into the description, if the nodes that use them don't already provide documentation that mentions them!

@spiffmon
Copy link
Member

Just a couple questions/sugs, but looks good overall, @JGamache-autodesk . Let us know if you plan on updating the PR?

@spiffmon
Copy link
Member

spiffmon commented Dec 1, 2022

@JGamache-autodesk , we might be able to get this into 23.02 if you can update the PR this week/early next week?

@JGamache-autodesk
Copy link
Contributor

Hi @spiffmon, I have a patch in my local repo. I will try to get it merged into the PR early next week.

seando-adsk and others added 2 commits December 5, 2022 10:10
All C strings were replaced by TfTokens.
Reinforced warning about unit divergence between MaterialX and USD.
@seando-adsk seando-adsk requested review from spiffmon and JGamache-autodesk and removed request for spiffmon December 5, 2022 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants