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

🐛 Fix instancing for Maya2020/2022 and don't rename refs #8

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
7 changes: 4 additions & 3 deletions lib/mayaUsd/fileio/translators/translatorMayaReference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ const bool useLegacyMayaRefNaming(const UsdPrim& prim)
{
// Check if the user requested that we use the legacy behavior for AL refs.
// If not, we treat all references with the new scheme.
if (!TfGetenvBool("MAYA_USD_ENABLE_MAYA_REFERENCE_LEGACY_BEHAVIOUR", false))
return false;
if (TfGetenvBool("MAYA_USD_ENABLE_MAYA_REFERENCE_LEGACY_BEHAVIOUR", false))
return true;

// MayaReference prims are using the new behaviour, others use the legacy behaviour.
const TfToken MayaReference("MayaReference");
Expand Down Expand Up @@ -526,9 +526,10 @@ MStatus UsdMayaTranslatorMayaReference::update(const UsdPrim& prim, MObject pare
if (!useLegacyScheme) {
// On reconnect, the Maya reference node is renamed to match
// the prim.
MString uniqueRefNodeName
/*MString uniqueRefNodeName
= getUniqueRefNodeName(prim, parentDag, tempRefFn);
tempRefFn.setName(uniqueRefNodeName);
*/

status = setMayaRefCustomAttribute(prim, tempRefFn);
CHECK_MSTATUS_AND_RETURN_IT(status);
Expand Down
6 changes: 4 additions & 2 deletions lib/mayaUsd/render/vp2RenderDelegate/mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2308,8 +2308,10 @@ void HdVP2Mesh::_UpdateDrawItem(
// prims. In case of multiple instances, we need to disable consolidation to allow
// GPU instancing to be used.
else if (newInstanceCount == 1) {
bool success = renderItem->setMatrix(&(*stateToCommit._instanceTransforms)[0]);
TF_VERIFY(success);
if (stateToCommit._instanceTransforms) {
bool success = renderItem->setMatrix(&(*stateToCommit._instanceTransforms)[0]);
TF_VERIFY(success);
}
} else if (newInstanceCount > 1) {
_SetWantConsolidation(*renderItem, false);
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,7 @@ void ProxyRenderDelegate::_UpdateSceneDelegate()
InstancePrototypePath ProxyRenderDelegate::GetPathInPrototype(const SdfPath& id)
{
HdInstancerContext instancerContext;
auto usdInstancePath = GetScenePrimPath(id, 0, &instancerContext);
auto usdInstancePath = GetScenePrimPath(id, UsdImagingDelegate::ALL_INSTANCES, &instancerContext);

// In case of point instancer, we already have the path in prototype, return it.
if (!instancerContext.empty()) {
Expand Down
3 changes: 1 addition & 2 deletions lib/mayaUsd/render/vp2ShaderFragments/shaderFragments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ MStatus HdVP2ShaderFragments::registerFragments()
}
}
}

#if MAYA_API_VERSION >= 20210000
{
// This is a temporary fix for Maya 2022 that is quite fragile and will need to be revisited
// in the near future. It will not handle the custom color space some large scale clients
Expand Down Expand Up @@ -535,7 +535,6 @@ MStatus HdVP2ShaderFragments::registerFragments()
LINREC709_TO_SCENE_LINREC709_REC_2020);
}

#if MAYA_API_VERSION >= 20210000

// Register automatic shader stage input parameters.
for (const auto& input : _automaticShaderStageInputs) {
Expand Down