-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[usdImaging] Allow prototypes from overs, per https://graphics.pixar.com/usd/docs/api/class_usd_geom_point_instancer.html#UsdGeomPointInstancer_protoProcessing #1436
Conversation
return _displayUnloadedPrimsWithBounds ? | ||
UsdPrimIsActive && UsdPrimIsDefined && !UsdPrimIsAbstract : | ||
UsdPrimDefaultPredicate; | ||
Usd_PrimFlagsConjunction retval = UsdPrimIsActive && !UsdPrimIsAbstract; |
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.
This is the same as
UsdPrimIsActive && !UsdPrimIsAbstract &&
(forPrototypes || UsdPrimIsDefined) &&
(_displayUnloadedPrimsWithBounds || UsdPrimIsLoaded);
Might make it easier to figure out what the patch does.
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.
Thanks Bill-- to me, it's more clear as is, but I'm happy to change it per your suggestion if there's a consensus to do so. Thanks for looking!
Filed as internal issue #USD-6552 |
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.
The additional ask we have is if you could turn your nice test file into a testusdview test, also enhancing it to cover the requested changes (I.e. add some defined geometry under an over inside of one of the prototypes and ensure it doesn't get processed). Super-extra bonus points if you have a nested PI that exercises the new logic, but won't hold you to that!
Thanks again, @asluk !
if (!forPrototypes) { | ||
retval = retval && UsdPrimIsDefined; |
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.
This is actually incorrect. Rather than just leaving out UsdPrimIsDefined
– which will wind up processing even "overs" underneath the top-most "over" – we want to substitute UsdPrimHasDefiningSpecifier
for UsdPrimIsDefined
, which essentially removes the "all ancestor prims must also be defined" clause from the traversal predicate, while still excluding additional overs from consideration.
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.
Thanks Spiff-- here's a zip that has a point instancer with a prototype in an over, and a def underneath, in sphereInstancer.usda -- it doesn't draw as expected unless I remove the UsdPrimHasDefiningSpecifier (or
UsdPrimIsDefined) in the predicate. Am I misunderstanding something?
There's also an ni_pi.usda in the zip that puts the point instancer behind scenegraph instancing. No predicate as yet seems to get that drawing as expected. I'll continue investigating, unless you already know what's going on.
I'll also study testusdview a bit and see about getting these smaller test cases into it.
Thanks again!
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.
Hmm.. the reason I thought this might not be working doesn't hold up. There's alot going on right now, but I'll try to take a deeper look and get back to you. First thing to check is whether, outside of imaging, the prototype root prims (which presumably are children of an undefined "over") pass the predicate. If they do not, then maybe we have a core bug.
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.
Hi Spiff, in the sphereInstancer.usda within the zip archive I posted above, I ran the following in usdview.
I think that is correct from a core standpoint, so I don't think there's a way to get the prototype detection logic to descend into overs without removing Usd.PrimHasDefiningSpecifier . But I think I understand your point that you want the prim range to descend into overs, but do not honor prototypes that themselves are pure overs. I'd have to think more about the right logic for that, if that's what the standard should be.
(I haven't had time to dig more into the nested instancing case yet in the zip archive).
Thanks!
(Dummy is an over, Dummy/sphere is a def)
[x for x in Usd.PrimRange( usdviewApi.stage.GetPrimAtPath('/World/Instancer'), Usd.PrimIsActive & Usd.PrimHasDefiningSpecifier & ~Usd.PrimIsAbstract & Usd.PrimIsLoaded)]
[Usd.Prim(</World/Instancer>)][x for x in Usd.PrimRange( usdviewApi.stage.GetPrimAtPath('/World/Instancer'), Usd.PrimIsActive & ~Usd.PrimIsAbstract & Usd.PrimIsLoaded)]
[Usd.Prim(</World/Instancer>), Usd.Prim(</World/Instancer/Dummy>), Usd.Prim(</World/Instancer/Dummy/sphere>)]
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 we were thinking, and what I thought the example showed, is that the parent of the prototypes (itself a child of the PI) would be a pure over. In our experience, having the prototypes themselves be overs would not even be practical to achieve, since they are references to defined models.
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.
That's correct-- in my attached scene, Dummy is a pure over beneath the PI, and Sphere is a def for the prototype under Dummy. But with UsdPrimHasDefiningSpecifier, traversals won't reach Dummy from the PI.
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.
But it shouldn't need to traverse from the PI, by my read of the code: https://github.com/PixarAnimationStudios/USD/blob/67af68bac3469b328e7f9dff9e0dc6e198ea7a5f/pxr/usdImaging/usdImaging/pointInstancerAdapter.cpp#L199-L233 . It explicitly starts from each prototype root, gleaned via the prototypes relationship. I'm not super familiar with this code, though.
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 point, Spiff. I reran the snippet above on the prototype root, which is a pure over with Sphere def'd under it.
[x for x in Usd.PrimRange( usdviewApi.stage.GetPrimAtPath('/World/Instancer/Dummy'), Usd.PrimIsLoaded & ~Usd.PrimIsAbstract & Usd.PrimIsActive)]
[Usd.Prim(</World/Instancer/Dummy>), Usd.Prim(</World/Instancer/Dummy/sphere>)]
[x for x in Usd.PrimRange( usdviewApi.stage.GetPrimAtPath('/World/Instancer/Dummy'), Usd.PrimIsLoaded & ~Usd.PrimIsAbstract & Usd.PrimIsActive & Usd.PrimHasDefiningSpecifier)]
[]
I think the predicate gets applied right away, which makes sense, so it won't descend below the pure over of Dummy.
I kept UsdPrimHasDefiningSpecifier out of the predicate, but now have it as a condition alongside checking for the adapter, such that pure overs are skipped, but defs that have ancestral overs are honored.
I'm still debugging the nested instancing case.
Thanks again!
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.
Aaron, I thought we’d agreed above yhat the proto roots themselves are not meant to be pure overs, but their parents can be... a “protos” Xform or scope, if you will. Can you keep to that design? Then we can have nice simple code.
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.
Sorry Spiff--- I've been scatterbrained. Fixed. Will continue investigating nested instances and regression testing.
f7fcfbe
to
67af68b
Compare
df8ea5b
to
0621f65
Compare
Hey @asluk ! Both your last force-push and the comment that you're still investigating happened 12 days ago. We were wondering if you're still working on this? Thanks! |
Hi Spiff! Yes, I'm still working on it, or rather it's still on my plate but backburnered as I investigate some other more pressing internal issues. I'll update here when I make more progress. Thanks! |
0621f65
to
5f02a57
Compare
Not quite ready for re-review yet; working out some kinks with the unit test. |
5f02a57
to
65a2620
Compare
Hi @spiffmon , I think this is ready for re-review now. I figured out what was happening with native/nested instances, and added a comment to instanceAdapter.cpp with those findings. The unit test has a point instancer inside of two native instances, and the point instancer has one prototype under an over, and one prototype that is itself an over, and thus ignored. Apologies for the delay! |
65a2620
to
4a61b0f
Compare
Added an additional test case to cover native instancing with overs as direct prototypes rather than in the nested point instancer prototype. |
Thanks, @asluk ! The code looks good, but when @tallytalwar ran our (unfortunately) internal tests with it, there were several failures, including geometry going missing in a test involving nested point and native instancing... which blows our minds a little because your change should be strictly more permissive! We'll need to make some time to dig into them - sorry for the delay! |
Update: @tcauchois got to the bottom of it! It's a case where a PI prototype is nested inside a native instance, we never traverse the native instance to find it because the root primof NI's has (early) all of its fields stripped out, including its specifier. We must be doing something special in the implementation of IsDefined that causes the root and all of its children to answer as if the root is defined, but HasDefiningSpecifier has no such special logic for prototype root prims. We have an imaging-side workaround for now, and we'll followup to hopefully address this at the Usd-level instead. |
Awesome-- much appreciated, @tcauchois and @spiffmon ! |
change 2160506. This test case was based on TF_DEBUG output which has been shown to be fragile in past test cases. The test case has been migrated to an internal test suite based on image comparisons that we hope to publish in the future. See #1436 (Internal change: 2160769)
Description of Change(s)
Allows instancer prototypes to come from within overs, as described in https://graphics.pixar.com/usd/docs/api/class_usd_geom_point_instancer.html#UsdGeomPointInstancer_protoProcessing and https://groups.google.com/g/usd-interest/c/RJnYoYWbgo8/m/Rh6UV2rlCwAJ . Tested with the attached City_set.
city_protos_over.zip