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

Use Render Delegate's material binding pupose #3352

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions pxr/imaging/hd/sceneIndexAdapterSceneDelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,11 +477,11 @@ _IsVisible(const HdContainerDataSourceHandle& primSource)
}

static SdfPath
_GetBoundMaterialPath(const HdContainerDataSourceHandle& ds)
_GetBoundMaterialPath(const HdContainerDataSourceHandle& ds, const TfToken& purpose)
{
if (const auto bindingsSchema = HdMaterialBindingsSchema::GetFromParent(ds)) {
if (const HdMaterialBindingSchema bindingSchema =
bindingsSchema.GetMaterialBinding()) {
bindingsSchema.GetMaterialBinding(purpose)) {
if (const HdPathDataSourceHandle ds = bindingSchema.GetPath()) {
return ds->GetTypedValue(0.0f);
}
Expand Down Expand Up @@ -514,7 +514,8 @@ static void
_GatherGeomSubsets(
const SdfPath& parentPath,
const HdSceneIndexBaseRefPtr& sceneIndex,
HdTopology* topology)
HdTopology* topology,
const TfToken& materialBindingPurpose)
{
TF_VERIFY(topology);
HdGeomSubsets subsets;
Expand Down Expand Up @@ -563,7 +564,7 @@ _GatherGeomSubsets(
}
continue;
}
const SdfPath materialId = _GetBoundMaterialPath(child.dataSource);
const SdfPath materialId = _GetBoundMaterialPath(child.dataSource, materialBindingPurpose);
if (materialId.IsEmpty()) {
continue;
}
Expand Down Expand Up @@ -631,8 +632,9 @@ HdSceneIndexAdapterSceneDelegate::GetMeshTopology(SdfPath const &id)
faceVertexCountsDataSource->GetTypedValue(0.0f),
faceVertexIndicesDataSource->GetTypedValue(0.0f),
holeIndices);

_GatherGeomSubsets(id, _inputSceneIndex, &meshTopology);

TfToken materialBindingPurpose = GetRenderIndex().GetRenderDelegate()->GetMaterialBindingPurpose();
_GatherGeomSubsets(id, _inputSceneIndex, &meshTopology, materialBindingPurpose);

return meshTopology;
}
Expand Down Expand Up @@ -841,7 +843,8 @@ HdSceneIndexAdapterSceneDelegate::GetBasisCurvesTopology(SdfPath const &id)
curveVertexCountsDataSource->GetTypedValue(0.0f),
curveIndices);

_GatherGeomSubsets(id, _inputSceneIndex, &result);
TfToken materialBindingPurpose = GetRenderIndex().GetRenderDelegate()->GetMaterialBindingPurpose();
_GatherGeomSubsets(id, _inputSceneIndex, &result, materialBindingPurpose);

return result;
}
Expand Down Expand Up @@ -916,8 +919,9 @@ HdSceneIndexAdapterSceneDelegate::GetMaterialId(SdfPath const & id)
HdMaterialBindingsSchema materialBindings =
HdMaterialBindingsSchema::GetFromParent(
prim.dataSource);
TfToken purpose = GetRenderIndex().GetRenderDelegate()->GetMaterialBindingPurpose();
HdMaterialBindingSchema materialBinding =
materialBindings.GetMaterialBinding();
materialBindings.GetMaterialBinding(purpose);
if (HdPathDataSourceHandle const ds = materialBinding.GetPath()) {
return ds->GetTypedValue(0.0f);
}
Expand Down