-
Notifications
You must be signed in to change notification settings - Fork 202
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
Add contextual menu to bind materials #2287
Add contextual menu to bind materials #2287
Conversation
- Adds a bind/unbind contextual menu to the outliner. The menu lists available materials to bind. - Extends the create reference menu to list all asset types that can be referenced. Includes MaterialX and Alembic files.
// | ||
// TODO: Show only materials that are inside of the asset's namespace otherwise there | ||
// will be "refers to a path outside the scope" errors. See | ||
// https://groups.google.com/g/usd-interest/c/dmjV5bQBKIo/m/LeozZ3k6BAAJ |
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.
Any idea how to do this?
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.
Afraid not.
@@ -48,6 +48,9 @@ Ufe::ConstAttributeDefs getAttrs(const PXR_NS::SdrShaderNodeConstPtr& shaderNode | |||
for (const PXR_NS::TfToken& name : names) { | |||
PXR_NS::SdrShaderPropertyConstPtr property | |||
= input ? shaderNodeDef->GetShaderInput(name) : shaderNodeDef->GetShaderOutput(name); | |||
if (!property) { | |||
continue; |
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 have third-party shaders crashing here. They registered the input names, but did not register a SdrShaderProperty.
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.
That would be a great code comment.
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.
Looks good to me! Just minor comments. Material discovery traversals are a bit worrisome, I will say, especially if this is used in a context where UI must be displayed synchronously, but I will assume that you feel the typical scene hierarchy where this will be used will not cause performance problems.
// | ||
// TODO: Show only materials that are inside of the asset's namespace otherwise there | ||
// will be "refers to a path outside the scope" errors. See | ||
// https://groups.google.com/g/usd-interest/c/dmjV5bQBKIo/m/LeozZ3k6BAAJ |
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.
Afraid not.
lib/mayaUsd/ufe/UsdContextOps.cpp
Outdated
// TODO: Introduce material binding via collections API | ||
// | ||
auto stage = fItem->prim().GetStage(); | ||
for (UsdPrim currentPrim : stage->TraverseAll()) { |
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.
How expensive can this traversal end up being?
@@ -48,6 +48,9 @@ Ufe::ConstAttributeDefs getAttrs(const PXR_NS::SdrShaderNodeConstPtr& shaderNode | |||
for (const PXR_NS::TfToken& name : names) { | |||
PXR_NS::SdrShaderPropertyConstPtr property | |||
= input ? shaderNodeDef->GetShaderInput(name) : shaderNodeDef->GetShaderOutput(name); | |||
if (!property) { | |||
continue; |
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.
That would be a great code comment.
- Traversing large scenes is not an option. Instead we traverse the selection to find materials either directly selected, or under a selected parent (Looks section). The workflow is now: - Select the materials or the looks section - Navigate in the outliner to the geometry you want to bind, and activate the context menu (this does not change selection). - If materials are found in the selection, they will be offered in a Bind Material context menu item. In UX terms, this forces you to pre-select the "object" before right clicking on the "subject" to get the Bind "verb" as an option. This is far from perfect, so I am open to any other solution that does not process the whole stage to find materials.
d764d99
available materials to bind.
be referenced. Includes MaterialX and Alembic files.