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

pxrUsdPreviewSurface opacity support broken following PR #574 #607

Closed
mattyjams opened this issue Jun 29, 2020 · 4 comments
Closed

pxrUsdPreviewSurface opacity support broken following PR #574 #607

mattyjams opened this issue Jun 29, 2020 · 4 comments
Assignees
Labels
bug Something isn't working import-export Related to Import and/or Export pxr Related to Pixar plugin vp2renderdelegate Related to VP2RenderDelegate

Comments

@mattyjams
Copy link
Contributor

mattyjams commented Jun 29, 2020

Describe the bug
Following the merge of #574, the pxrUsdPreviewSurface shading node now uses the fragment graph XML from the VP 2.0 render delegate instead of its own version. One important difference there is that the render delegate version uses an opacity property instead of a transparency property. There were no changes to pxrUsdPreviewSurface or its shading node override to account for this, so as a result the opacity control on pxrUsdPreviewSurface is no longer working.

This was uncovered by running the testPxrUsdPreviewSurfaceDraw test internally at Pixar after merging the PR. This test is unfortunately not being run in the open source repo.

I was able to fix the issue by reverting the UsdPreviewSurface fragment graph in vp2ShaderFragments to use transparency instead as it did before it was copied there from pxrUsdPreviewSurface. That change can be seen in mattyjams@1a6628a.

I'm not exactly sure how or if that fragment graph is used by the VP2.0 render delegate, but I would guess that we don't actually want to fix this that way. It would seem then that we need to modify the shading node override for pxrUsdPreviewSurface, and/or modify the shading node itself. I remember running into problems though when writing the node because of the inversion from opacity to transparency, and the fact that the attribute declared in transparencyParameter() of the override seems to be expected to have "transparency" semantics (zero is fully opaque and one is fully transparent).

Steps to reproduce
Open the test scene here:
https://github.com/Autodesk/maya-usd/blob/dev/test/lib/usd/pxrUsdPreviewSurface/PxrUsdPreviewSurfaceDrawTest/PxrUsdPreviewSurfaceDrawTest.ma

You should notice that in the third "column" from the right, the spheres are all opaque and ramp from solid white at the front to middle gray in the back.

This is the image being produced when I run the test:
PxrUsdPreviewSurfaceDrawTest_value_ramps_broken_opacity

Expected behavior
The spheres in the third "column" from the right should ramp from fully transparent to fully opaque, matching the baseline image here:
https://github.com/Autodesk/maya-usd/blob/dev/test/lib/usd/pxrUsdPreviewSurface/PxrUsdPreviewSurfaceDrawTest/baseline/PxrUsdPreviewSurfaceDrawTest_value_ramps.png
PxrUsdPreviewSurfaceDrawTest_value_ramps_baseline

Specs

@mattyjams mattyjams added the bug Something isn't working label Jun 29, 2020
@santosd santosd added the pxr Related to Pixar plugin label Jun 29, 2020
@huidong-chen
Copy link

huidong-chen commented Jun 29, 2020

@mattyjams Thanks for reporting the issue.

The intention of the change to the render delegate version of UsdPreviewSurface.xml is to generate the opacity vertex stream requirement, which we can directly fill with the floating point primvars:displayOpacity data. Then in CPU side we can avoid a loop to invert the displayOpacity array to transparency.

Instead of your proposal, can we do it this way?

  • Extract the core of UsdPreviewSurface shader fragment graph as UsdPreviewSurfaceCore, which will match the Pixar version. The Pixar shading node override will need a minor change to use UsdPreviewSurfaceCore.
  • UsdPreviewSurface connects opacityToTransparency as input to the core and wraps both with a fragment graph.

I think in this way we can ensure both sides can work as expected. Let me know what you think.

By the way, the render delegate version has had another change to support multiple Maya lights, so the Pixar shading node override will also benefit from the merge of PR #574 .

@huidong-chen
Copy link

huidong-chen commented Jun 29, 2020

I forgot that the more important reason of the change is that we try to match the shader fragment parameter names with the UsdPreviewSurface property names, in order to update shader parameters without manual conversion.

My above proposal is not changed.

@mattyjams
Copy link
Contributor Author

Thanks for the notes here, @HdC-adsk. I just implemented your proposed solution in #626. Let me know what you think!

@huidong-chen huidong-chen added the import-export Related to Import and/or Export label Jul 7, 2020
@mattyjams
Copy link
Contributor Author

Addressed by #626. Thanks again, @HdC-adsk!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working import-export Related to Import and/or Export pxr Related to Pixar plugin vp2renderdelegate Related to VP2RenderDelegate
Projects
None yet
Development

No branches or pull requests

4 participants