-
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
[USD] Adding position interpolation to points. #214
[USD] Adding position interpolation to points. #214
Conversation
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 great, Pal! I'll follow up with you again about the last comment once we get our story straight internally.
pxr/usd/lib/usdGeom/points.cpp
Outdated
@@ -238,4 +238,82 @@ TF_REGISTRY_FUNCTION(UsdGeomBoundable) | |||
_ComputeExtentForPoints); | |||
} | |||
|
|||
size_t | |||
UsdGeomPoints::ComputePositionsAtTimes( | |||
std::vector<VtVec3fArray>& positions, |
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.
Apologies for not documenting them yet, but our coding conventions call for "out" parameters to be passed by pointer, so that it is obvious reading call sites which are which.
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 for the heads up. I'll keep this in mind for the next time.
pxr/usd/lib/usdGeom/points.cpp
Outdated
VtVec3fArray velocities; | ||
|
||
// We need to check if there is a queriable velocity at the given point, | ||
// if it has almost the same lower time sample and the array lengths are equal. |
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.
Why is it important that velocity be sampled at the same stride as points? I get that in most FX-exported data it will be, but it seems legit to establish a constant velocity field, or one that varies more or less slowly than the points? Velocity varying faster than the points is problematic, I get, since we'd need to establish some integration rules.
If we do want to start out trying to limit algorithmic complexity (which I'll buy!) then I don't think it's sufficient to require the lower-bound sample ordinates to match: you must also require the upper-bounds to match, also, lest your requested sampleTimes cross over a new sample of velocities.
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.
Right, I forgot about the uses of a constant velocity field, or varying frequency. Updated the code to require both times to match.
pxr/usd/lib/usdGeom/points.cpp
Outdated
|
||
const auto idsAttr = GetIdsAttr(); | ||
VtArray<long> ids; | ||
if (!idsAttr.Get(&ids, sampleTimes[0])) { return 1; } |
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.
I don't think that unauthored ids should result in failing to try to interpolate. Fixed topology for any PointBased should be legit and blurrable?
More broadly, these ID checks is the only thing preventing this lovely computation from being promotable to PointBased. We definitely sometimes have varying topology meshes with authored velocities in our pipeline, and I'd love for Katana (and Hydra) to just be able to call this computation for all PointBased. With the unfortunate lame-o disclaimer that we still haven't gotten to adding infrastructure for it (though momentum is building for its need), these ID checks seem better suited to validation, which would be something you could initiate from usdview or a script.
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.
Sure. I'll remove the ID checks for now, and just use the built-in interpolation for points. I'll check for point lengths though. Also, this means I can move the function back to pointBased. (my original implementation was there, but I promoted it to points because of the extra id checks)
pxr/usd/lib/usdGeom/points.h
Outdated
/// In the case of fallback to traditional interpolation, the function will try to | ||
/// confirm that the Ids are consistent across multiple position samples. In case | ||
/// of missing Ids, only the first sample will be filled out. Otherwise, the function | ||
/// will go as long as it can find a consistent "topology" for the points. |
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.
Just a note to update docs if we change behaviors
!GfIsClose(e1[1], e2[1], epsilon) || | ||
!GfIsClose(e1[2], e2[2], epsilon)) { | ||
return false; | ||
} |
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.
We do specialize GfIsClose for GfVec3f, so you could simplify this function.
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! I missed that. Rewrote the code to use the specialization.
// we can use the size of this vector as a simple test for whether motion | ||
// blur is enabled, without needing access to the cook interface. | ||
const std::vector<double>& motionSampleTimes = | ||
data.GetUsdInArgs()->GetMotionSampleTimes(); |
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.
There is actually important logic in PxrUsdKatanaUsdInPrivateData::GetMotionSampleTimes() beyond what the UsdInArgs version does. I think you should call it here on the "points" attr. That said, there is some craziness regarding IsMotionBackwards() that we are trying to work through right now, so that we can get the PointInstancer and your new code doing the right thing in both forwards and backwards motion blur (we do backwards here, but want to make sure not to foist that decision on everyone). I'll contact you again when we get it sorted, which should hopefully be soon.
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. Let me know once it's done, and I'll update the change asap.
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.
OK, I think it's actually pretty simple, given how you've structured the computation so nicely to take 'baseTime' as a separate input to the sample times.
const std::vector<double> motionSampleTimes = data.GetMotionSampleTimes(points.GetPointsAttr());
// Instead of consulting shutterOpen/shutterClose to build up sampleTimes, iterate through
// motionSampleTImes, adding currentTime to each element, since the fn returns frame-relative
// times
I plan to lobby to get this moved up to applying to all PointBased prims in Katana, but probably OK to leave it just on Points to start.
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.
@spiffmon Done! Both using the points attr in the query and all the motion samples, not just the shutter open and close.
1b89fab
to
76911ed
Compare
Filed as internal issue #147139. |
fe177ba
to
725f2d5
Compare
Looks great, Pal - will get this on the queue for merging!
…On 06/05/2017 03:54 PM, Pal Mezei wrote:
***@***.**** commented on this pull request.
-----------------------------------------------------------------------------
In third_party/katana/lib/usdKatana/readPoints.cpp
<#214 (comment)>:
> @@ -34,6 +34,49 @@ PXR_NAMESPACE_OPEN_SCOPE
static FnKat::Attribute
+_GetPositionAttr(
+ const UsdGeomPoints& points,
+ const PxrUsdKatanaUsdInPrivateData& data)
+{
+ // Because of the logic used to gather these (in PxrUsdInOp::InitUsdInArgs),
+ // we can use the size of this vector as a simple test for whether motion
+ // blur is enabled, without needing access to the cook interface.
+ const std::vector<double>& motionSampleTimes =
+ data.GetUsdInArgs()->GetMotionSampleTimes();
@spiffmon <https://github.com/spiffmon> Done! Both using the points attr in
the query and all the motion samples, not just the shutter open and close.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#214 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AF7qaCj759b7_ZwrJUUj39EMYE6XiyB4ks5sBIcegaJpZM4NkfW3>.
|
Hi Pal, Concretely (and this is why I didn't catch it at first), it means changing how you use the results of GetBracketingTimeSamples() - the last out parameter is not telling you there's no value, only that there are no timeSamples. What we're proposing is that in the case where points are authored but have no timeSamples, is to treat it exactly as if there were no velocity, as your "else" clause for "if (velocityExists)" already does exactly what we'd expect for this state of authored data (i.e. it will give you back N identical samples). Does that make sense? Thanks! |
Yes, absolutely! I'll get the PR updated soon, and keep this in mind for future PRs. |
OK, I promise, this is the last thing! Can you add an optional, out parameter for returning the velocity vector (as VtArray) that you used, if any? And then make readPoints use that value to populate the Points location's point.v attr? Here's why: Thanks for bearing with me, Pal! |
a8d3355
to
47606a7
Compare
@spiffmon Updated the PR with both of the changes requested! Let me know if you need anything else, eager to update the PR to make sure everybody is happy. :) |
Thanks, Pal! I think the rest is on us: we are weighing two possibilities for how to continue to support authored velocityScale in Katana that is accessible to pxrUsdIn; once we have one we'll be able to pull in your readPoints.cpp code.
…--spiff
On Jun 21, 2017, at 9:12 PM, Pal Mezei ***@***.***> wrote:
@spiffmon Updated the PR with both of the changes requested!
Let me know if you need anything else, eager to update the PR to make sure everybody is happy. :)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Sorry, pressed the wrong button. |
47606a7
to
4ae8a56
Compare
Description of Change(s)
The PR adds a new function, ComputePointsAtTimes to UsdGeomPoints, including tests and python bindings.
The goal of the change is to have an easy to use interface to calculate velocity based interpolation for points, and in the case of no velocity fall back to the built-in interpolation mode. The change also updates the katana point-reader, so interpolated positions will are generated at shutter open and close. For example, with this change, Arnold in Katana interpolates particles nicely.