How does uvsample work?

   5152   5   5
User Avatar
Member
132 posts
Joined: July 2007
Offline
I'm trying to use uvsample (vex function) to interpolate point positions along a curve based on a custom attribute that I've uniformly added to a non-uniformly-spaced poly line.
I try this:
vector ptPos = uvsample(0, “P”, “myAttrib”, {0.5, 0});

And what I get back is a point position based not on my myAttrib value, but the implicit u coordinates in the curve (which are not length-uniform).
In fact, I can change myAttrib to any string and get the same results. As if it's not seeing my myAttrib point attribute at all. But the geo spreadsheet shows it correctly.

Can anyone tell (or show) me how this is supposed to work? I'm either confused or it's broken (16.0.705 Indie).

Thanks ahead of time!
-Len
User Avatar
Member
252 posts
Joined:
Offline
Hi, this has got me curious..
I did a some testing, so far it seems that it only *works* with primitives, not curves/polylines.

Have a look at the attached file, hopefully I'm using it correctly.

It would be neat if it didn't snap to the nearest found “P”, but instead should just return an interpolated point position. Maybe the function does have a bug?

H16.0.745 Indie

Attachments:
uvsample.zip (12.0 KB)

User Avatar
Member
483 posts
Joined: Dec. 2006
Offline
https://www.sidefx.com/forum/topic/52270/ [www.sidefx.com]

maybe helpy?
English is not my native language, sorry in advance for any misunderstanding :-)
User Avatar
Staff
4162 posts
Joined: Sept. 2007
Offline
You can texture the curves in Rows & Columns mode, then use primuv() [www.sidefx.com] to lookup the interpolated values based on UVs. This example uses VOPs, but the same can be achieved with a wrangle.

Hope that helps!

(edit: didn't see that link in the last post, which is also suggesting primuv!)
Edited by goldleaf - Oct. 25, 2017 21:37:15

Attachments:
lookup_uv_rows_cols.hipnc (179.2 KB)
screenshot-area-2017-10-25-211518.png (18.6 KB)
screenshot-area-2017-10-25-211536.png (9.9 KB)

I'm o.d.d.
User Avatar
Member
132 posts
Joined: July 2007
Offline
Hey! Thanks for all the ideas and examples.
In terms of the original question: How is upsample intended to work, I think @galagast probably has the real answer, in that it doesn't work for my intended target, polylines.
@goldleaf, your example is very cool but I don't think it gets at the core of what I'm trying to solve: I have non-evenly-sampled polylines (different length segments between points) and want to get points at set distances along the curve from a given point along the curve.
Basically interpolating points but by distance instead of the non-evenly distributed U coordinates that most (or all) of Houdini's tools want to work with.
I've tried setting the u values to be distance-based, but that seems impossible on polylines (discovering along the way the distinct difference between parametric ‘implicit’ u-coordinate and u, in terms of texturing, coordinate).

So I thought, if upsample() lets me use another attribute, besides the non-editable U-coordinate, I can pump it with my correctly-valued attribute (e.g. “distanceAlong” or something like that) and get points at specified distances from any reference point. But, looks like that won't work in this case.
User Avatar
Member
2 posts
Joined: Nov. 2014
Offline
Resample curve by length, then interpolate ?
  • Quick Links