-
Notifications
You must be signed in to change notification settings - Fork 4
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
Lanierd/hydra 311 #149
Conversation
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 pretty good to me, only minor questions / comments.
MSelectionList list; | ||
MObject node; | ||
|
||
// Add the shader to the selection list | ||
list.add("standardSurface1"); | ||
|
||
// Get the shader as an MObject | ||
list.getDependNode(0, node); |
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.
Nit-pick: isn't this just GetDependNodeFromNodeName("standardSurface1", node)
?
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.
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; |
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.
Where does 0.8f come from?
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 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;} |
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.
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 |
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.
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( |
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.
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.
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.
There is only one at this time, do you think I should switch to a std::set now ?
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.
No, just add a comment mentioning this as a possibility if the defaultMaterialExclusionList becomes large.
Support default material switching in the maya hydra viewport through a scene index