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

Add opacity threshold to USD Preview Surface Shader #917

Merged
merged 1 commit into from
Nov 17, 2020

Conversation

dgovil
Copy link
Collaborator

@dgovil dgovil commented Nov 12, 2020

Opacity Threshold is an attribute on the USD preview surface shader that wasn't previously exposed to Maya, however is useful for artists to define the cutoff level for their opacity maps.

This exposes it in the attribute editor, makes sure it serializes properly to USD and that it clips the opacity accordingly.

There's a very minimal test included here that we used to check after merging upstream commits, but I hope we can add more material serialization tests in the future so I'm including it here.

@kxl-adsk kxl-adsk added the import-export Related to Import and/or Export label Nov 12, 2020
@classmethod
def setUpClass(cls):
cmds.loadPlugin('mayaUsdPlugin')
cls.temp_dir = tempfile.mkdtemp()
Copy link
Collaborator

Choose a reason for hiding this comment

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

You might want to consider moving this test to test/lib/usd/translators
In that folder there are utilities that will help setup a full test environments in the build area where the output files will be preserved, allowing easy investigation in case of problems. Look for inputPath = fixturesUtils.setUpClass(__file__) in files like https://github.com/Autodesk/maya-usd/blob/dev/test/lib/usd/translators/testUsdExportRfMShaders.py

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@JGamache-autodesk Thanks! I'll switch over our tests to live there. Quick question regarding naming...
I've been calling our tests testMayaUsdxxx but the ones in the translator section are testUsdxxx or textUsdMayaxxx. Which naming should I be going with?

Choose a reason for hiding this comment

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

We haven't really set any naming convention for tests other than it should start with test. For translators, please follow the naming convention you see in https://github.com/Autodesk/maya-usd/blob/dev/test/lib/usd/translators/, i.e. testUsdxxx.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Okay moved this over.

@dgovil dgovil force-pushed the opacity-threshold branch 2 times, most recently from e7112a3 to a4ba188 Compare November 16, 2020 18:59
Copy link
Contributor

@mattyjams mattyjams left a comment

Choose a reason for hiding this comment

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

Thanks for this @dgovil! Just two things I think we should address before it goes in:

  • I don't think we need opacityThresholdAttr to be public/static, especially since none of the other attributes are.
  • I think we want to use < instead of <= when testing the threshold.

Other than that, what's here looks good to me!

Note though that this is only part of the story. What's in compute() really only comes into play for software renders, or in preparation for feeding values into the shading fragment graph, so there's another chunk of work to this where we'd want to add support for opacityThreshold in the viewport.

We used to have a mechanism for keeping USD's previewSurface.glslfx and the shading fragments used by pxrUsdPreviewSurface in sync (or at least flagging when they were out of sync) back when they were both in the core USD repo, but since the split we've lost that. There have been a bunch of other changes to USD's implementation recently and I've been meaning to take a pass at sync'ing the two back up again.

lib/usd/pxrUsdPreviewSurface/usdPreviewSurface.cpp Outdated Show resolved Hide resolved
lib/usd/pxrUsdPreviewSurface/usdPreviewSurface.cpp Outdated Show resolved Hide resolved
lib/usd/pxrUsdPreviewSurface/usdPreviewSurface.h Outdated Show resolved Hide resolved
@dgovil
Copy link
Collaborator Author

dgovil commented Nov 16, 2020

@mattyjams I fixed up your notes. Agreed, that this doesn't resolve the actual shader work. We hadn't really bothered on our end since shader transparency was broken till recently. If/when you do sync up the shaders, that would be great.

Copy link
Contributor

@mattyjams mattyjams left a comment

Choose a reason for hiding this comment

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

Cool, thanks @dgovil! Looks great now!

No problem about the viewport support. I'll see if I can carve out any time to take a crack at that myself in the next few weeks.

@kxl-adsk kxl-adsk added the ready-for-merge Development process is finished, PR is ready for merge label Nov 16, 2020
@kxl-adsk
Copy link

@mattyjams

We used to have a mechanism for keeping USD's previewSurface.glslfx and the shading fragments used by pxrUsdPreviewSurface in sync (or at least flagging when they were out of sync) back when they were both in the core USD repo, but since the split we've lost that. There have been a bunch of other changes to USD's implementation recently and I've been meaning to take a pass at sync'ing the two back up again.

Yes, we are aware of this too. It's a task on our end as well, but we haven't got a chance to prioritize it yet.

@kxl-adsk kxl-adsk merged commit 264dd89 into Autodesk:dev Nov 17, 2020
@dgovil dgovil deleted the opacity-threshold branch November 20, 2020 05:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
import-export Related to Import and/or Export ready-for-merge Development process is finished, PR is ready for merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants