Skip to content

Conversation

@roggiezhang-nv
Copy link
Contributor

Description of Change(s)

Switching material bindings for skeletal meshes may cause out of sync issue.

See #1747 for more details.

Link to proposal (if applicable)

Fixes Issue(s)

#1747

Checklist

@roggiezhang-nv
Copy link
Contributor Author

@nvmkuruc for vis

@roggiezhang-nv roggiezhang-nv changed the title Fix issue of switching material bindings for skeletal mesh NVIDIA: Fix issue of switching material bindings for skeletal mesh Feb 24, 2025

// Bring up Hydra
Hd_UnitTestNullRenderDelegate renderDelegate;
std::unique_ptr<HdRenderIndex>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Core guidelines recommends creating these via make_unique.

https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rr-make_unique

Copy link
Member

Choose a reason for hiding this comment

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

(I assume you are pointing to the following new, not the New factory function, switching to make_unique here would lose the error check New performs.)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yup! I don't think we use make_unique with HdRenderIndex because the constructor is private.

@jesschimein
Copy link
Collaborator

Filed as internal issue #USD-10696

(This is an automated message. See here for more information.)

@jesschimein
Copy link
Collaborator

/AzurePipelines run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@roggiezhang-nv roggiezhang-nv force-pushed the material_sync branch 3 times, most recently from cb6161b to d066dbf Compare February 25, 2025 04:15
@jesschimein
Copy link
Collaborator

/AzurePipelines run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

// Switch the material on the head first
auto headPrim = stage->GetPrimAtPath(SdfPath("/Root/Geometry/head"));
TF_AXIOM(headPrim);
auto materialBinding = headPrim.GetRelationship(TfToken("material:binding"));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not a huge deal, but it might be nice to use the schema here if possible.

TF_AXIOM(materialBinding);
materialBinding.SetTargets({SdfPath("/Root/Looks/green")});

delegate->SetTime(0);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this second SetTime necessary to produce the issue?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think so. SetTime(0) is a way to apply all pending changes to setup dirty bits of all prims inside renderindex. That's a necessary step.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe I should replace them with ApplyPendingUpdates so it's more straightforward. Actually, SetTime(0) calls ApplyPendingUpdates inside.

// Switch the material on the neck
auto neckPrim = stage->GetPrimAtPath(SdfPath("/Root/Geometry/neck"));
TF_AXIOM(neckPrim);
materialBinding = neckPrim.GetRelationship(TfToken("material:binding"));
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd recommend avoiding reuse of the variables if possible. You can put the two switches into different scopes so the lifetime is clearer.

materialBinding = neckPrim.GetRelationship(TfToken("material:binding"));
TF_AXIOM(materialBinding);
materialBinding.SetTargets({SdfPath("/Root/Looks/green")});
delegate->SetTime(0);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is the SetTime necessary to produce the bug?

@jesschimein
Copy link
Collaborator

/AzurePipelines run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@pixar-oss pixar-oss closed this in 31ef7f3 Jun 12, 2025
meshula pushed a commit to meshula/USD that referenced this pull request Sep 11, 2025
Switching material bindings for skeletal meshes may cause out of sync issue.

Fixes PixarAnimationStudios#1747
Closes PixarAnimationStudios#3542

(Internal change: 2369214)
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.

4 participants