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

Lanierd/hydra 311 #149

Merged
merged 13 commits into from
Jul 18, 2024
Merged

Lanierd/hydra 311 #149

merged 13 commits into from
Jul 18, 2024

Conversation

lanierd-adsk
Copy link
Collaborator

Support default material switching in the maya hydra viewport through a scene index

@lanierd-adsk lanierd-adsk self-assigned this Jul 18, 2024
@lanierd-adsk lanierd-adsk self-assigned this Jul 18, 2024
@lanierd-adsk lanierd-adsk requested a review from ppt-adsk July 18, 2024 14:02
Copy link
Collaborator

@ppt-adsk ppt-adsk left a comment

Choose a reason for hiding this comment

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

Looks pretty good to me, only minor questions / comments.

Comment on lines 189 to 196
MSelectionList list;
MObject node;

// Add the shader to the selection list
list.add("standardSurface1");

// Get the shader as an MObject
list.getDependNode(0, node);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit-pick: isn't this just GetDependNodeFromNodeName("standardSurface1", node)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ha sorry, I missed that function, I will use it now.

@@ -1685,4 +1634,55 @@ bool MayaHydraSceneIndex::passNormalsToHydra()
return val;
}

VtValue MayaHydraSceneIndex::_CreateDefaultMaterialFallback()
{
static const MColor kDefaultGrayColor = MColor(0.5f, 0.5f, 0.5f) * 0.8f;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Where does 0.8f come from?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't know, it could be anything else, I guess I've picked it up from a maya shader, but that is arbitrary as this fallback shader should not be used.

//Sdfpath of the maya default material
SdfPath GetDefaultMaterialPath() const{return _mayaDefaultMaterialPath;}

bool GetDefaultMaterialAlreadyCreated() const{return _defaultMaterialCreated;}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Accessor name is a bit wordy, I like following the name of the member variable DefaultMaterialCreated(), or if you really want IsDefaultMaterialAlreadyCreated()

@@ -252,6 +258,9 @@ class MAYAHYDRALIB_API MayaHydraSceneIndex : public HdRetainedSceneIndex, public
/// Is using an environment variable to tell if we should pass normals to Hydra when using the render item and mesh adapters
static bool passNormalsToHydra();

///Create the default material from the "standardsurface1" maya material or create a fallback material if it cannot be found
Copy link
Collaborator

Choose a reason for hiding this comment

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

Seen this one in a few places, name of the default material is camelCase standardSurface1, not standardSurface1.

HdPathDataSourceHandle bindingPathDS = binding.GetPath();
if (bindingPathDS) { // If a mesh prim has no material( bindingPathDS is empty), apply anyway the default material
const SdfPath materialPath = bindingPathDS->GetTypedValue(0.0f);
auto foundExcludedMaterialPath = std::find(
Copy link
Collaborator

Choose a reason for hiding this comment

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

What size is this _defaultMaterialExclusionList expected to be? We are looping over this for each prim. If the list size is small, it's fine, but otherwise we can consider using an std::set.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There is only one at this time, do you think I should switch to a std::set now ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

No, just add a comment mentioning this as a possibility if the defaultMaterialExclusionList becomes large.

@lanierd-adsk
Copy link
Collaborator Author

@lilike-adsk lilike-adsk merged commit 10004a9 into dev Jul 18, 2024
10 checks passed
@lilike-adsk lilike-adsk deleted the lanierd/HYDRA-311 branch July 18, 2024 15:34
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.

3 participants