-
Notifications
You must be signed in to change notification settings - Fork 201
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
Fix VP2 rendering of UsdPreviewSurface with opacityThreshold #3947
Open
jufrantz
wants to merge
8
commits into
Autodesk:dev
Choose a base branch
from
jufrantz:fix_preview_surface_opacity_threshold
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3a29045
Fix opacityThreshold was not exposed as a property in the UsdPreviewS…
jufrantz 7fd21a5
Fix UsdPreviewSurface should be fully opaque when the input opacity i…
jufrantz 43d61cc
Test UsdPreviewSurface opacityThreshold cut-outs.
jufrantz 2319620
Updated baseline images for testVP2RenderDelegateDrawModes to reflect…
jufrantz 02c65c1
Fix testVP2RenderDelegateUSDPreviewSurface for maya 2022 (ufe v2).
jufrantz 5bc1a66
Merge branch 'dev' into fix_preview_surface_opacity_threshold
jufrantz 1ca8787
Skip testOpacityThreshold with Maya light API v1.
jufrantz 661ea9d
UsdPreviewSurface shading nodes with opacityThreshold are now VP2 ren…
jufrantz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Can you replicate the
opacityConnected
code you see foropacity
, but onopacityThreshold
? A connectedopacityThreshold
should also activate masked mode.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.
Thank you @JGamache-autodesk for your feedback,
Interesting point, but I think I disagree with this solution.
As you know, marking the whole material as
transparent
informs the rasterizer to use alpha blending for proper rendering (e.g. GL_BLEND and object sorting). Conversely,opaque
material allows the rasterizer to perform simple depth testing and overwrite fragments. Moreover formasked
materials, some fragments will be discarded without writing to the depth or color buffers, which still works with simple depth testing.OpacityThreshold
functions similarly to a combination of glTFalphaMode
andalphaCutoff
. For a material with authored opacity:opacityThreshold
is equivalent toglTF.alphaMode = BLEND
glTF.alphaMode=MASK
andglTF.alphaCutoff=opacityThreshold
.Texturing
opacityThreshold
is akin to texturing bothalphaCutoff
ANDalphaMode
: since you can get zero-valued threshold texels, you would expect a partiallymasked
and partiallytranslucent
material. In this scenario, to ensure proper rendering of the semi-transparent regions, the only viable solution to me is to render these objects in the transparent pass (that would also still work with alpha cut/discarded regions).For reference, HdStorm’s implementation of
masked
detection for GLSLFX UsdPreviewSurface only tests for a constant positiveopacityThreshold
value, while fortranslucent
it tests opacity input connections and decides that a varying opacity differs from plain one, like the current VP2 shading node implementation.https://github.com/PixarAnimationStudios/OpenUSD/blob/59992d2178afcebd89273759f2bddfe730e59aa8/pxr/imaging/hdSt/materialNetwork.cpp#L75-L83
Moreover, I may have over-interpreted it but - as I understand it - the USDPreviewSurface Specification discourages a material with a texture used for translucency and mask.
If we want to improve this, an alternative could be to disallow connections to the opacityThreshold parameter during VP2 shader translation. This restriction can be implemented with MPxShadingNodeOverride.
maya-usd/lib/usd/pxrUsdPreviewSurface/usdPreviewSurfaceShadingNodeOverride.cpp
Line 86 in dae864e
Please let me know if this approach meets your requirements,
Best,
Julien
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.
Good explanation. I agree with you. This would mean the implementation of _GetUsdPreviewSurfaceMaterialTag() I added to materialXFilter.cpp is buggy since it considers textured
opacityThreshold
as masked.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.
Probably no need to forbid connections since the result is not fatal and will render correctly, albeit slowly, in a transparency pass.