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

HYDRA-1103 : Update face selection shader to behave as an unlit shader #147

Merged
Merged
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
16 changes: 12 additions & 4 deletions lib/mayaHydra/hydraExtensions/sceneIndex/mayaHydraSceneIndex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -687,16 +687,24 @@ VtValue MayaHydraSceneIndex::CreateMayaDefaultMaterial()
VtValue MayaHydraSceneIndex::CreateMayaFacesSelectionMaterial()
{
const GfVec4f faceSelectioncolor = getPreferencesColor(FvpColorPreferencesTokens->faceSelection);

constexpr float ogsMatchParamMult = 0.3f;
HdMaterialNetworkMap networkMap;
HdMaterialNetwork network;
HdMaterialNode node;
node.identifier = UsdImagingTokens->UsdPreviewSurface;
node.path = _mayaFacesSelectionMaterialPath;

// Diffuse
node.parameters.insert(
{ _tokens->diffuseColor,
VtValue(GfVec3f(faceSelectioncolor[0], faceSelectioncolor[1], faceSelectioncolor[2])) });
node.parameters.insert({ _tokens->opacity, VtValue(float(0.3f)) });
{ _tokens->diffuseColor,
VtValue(GfVec3f(faceSelectioncolor[0], faceSelectioncolor[1], faceSelectioncolor[2])*ogsMatchParamMult) });

// Emissive (component selection highlighting material should be independent of scene lighting)
node.parameters.insert(
Copy link
Collaborator

Choose a reason for hiding this comment

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

This will make the shader be visible when there is no lights, but I think the problem was also that it should not receive lighting at all, I don't think this resolves this problem, right ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The face selection should be visible even when there are no lights. Isn't that the required behavior? Selection highlighting should be independent of scene lighting. Maya VP2 face sel highlight is visible even when no scene lights are used(Lighting>Use No Lights)

Copy link
Collaborator

Choose a reason for hiding this comment

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

The 0.3 magic constant seems to appear in 3 places, lines 700, 705, and 707. Any reason for that choice? And why not factor it out?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The magic constant is based on VP2's shader behavior. Good idea to factor it out.

{ _tokens->emissiveColor,
VtValue(GfVec3f(faceSelectioncolor[0], faceSelectioncolor[1], faceSelectioncolor[2])*ogsMatchParamMult) });

node.parameters.insert({ _tokens->opacity, VtValue(ogsMatchParamMult) });
network.nodes.push_back(std::move(node));
networkMap.map.insert({ HdMaterialTerminalTokens->surface, std::move(network) });
networkMap.terminals.push_back(_mayaFacesSelectionMaterialPath);
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ def test_MayaFaceComponentsPicking(self):
cmds.modelEditor(panel, edit=True, smoothWireframe=True)
cmds.refresh()
self.assertSnapshotClose("smoothwireframe" + ".png", self.IMAGE_DIFF_FAIL_THRESHOLD, self.IMAGE_DIFF_FAIL_PERCENT)

#Add lights
cmds.directionalLight(rotation=(45, 30, 15))
cmds.modelEditor(panel, edit=True, displayAppearance="smoothShaded")
cmds.modelEditor(panel, edit=True, displayLights="all")
cmds.select( 'pSphere1.f[1:200]', r=True )
cmds.refresh()
self.assertSnapshotClose("selectionWithLights" + ".png", self.IMAGE_DIFF_FAIL_THRESHOLD, self.IMAGE_DIFF_FAIL_PERCENT)

if __name__ == '__main__':
fixturesUtils.runTests(globals())