# Distance Based Point Sort?

## Recommended Posts

Is it possible to sort points based on their distance between each other?

For example if there is a group of randomly sorted points scattered along some curve, I'd like to resample them to restore the curved shape.

Peter

##### Share on other sites

Off the top of my head you could try this, put down an attribute create and add a point attribute called dist then ray the points onto the curve and select add "dist" attribute. Then in the sort sop use sort of expression with \$DIST in it. I haven't tried this but something like that should work.

##### Share on other sites

... ray the points onto the curve and select add "dist" attribute.

21898[/snapback]

I must be missing something, but there is nothing about attributes in ray SOP ?

My general idea was a bit different, maybe I explained it wrong. I wanted to sort the points without any user input needed.

There is a bunch of points which should be sorted based on their distance between each other so I could feed it to add SOP and create a curve.

I'd like add SOP to create a line following the shape of the point cloud, connecting the closest points, not some crazy uncontrollable zigzag.

I thought about using a neighbour VOP to add custom attribute values and feed this attribute into add SOP to create a line "by attribute", but VOPs are not my strongest side yet:).

This should be possible by cycling through the points, finding the closest neighbour for each next one and assigning next attribute value to it.

But even if this idea is ok, I don't know how to use it.

##### Share on other sites

In general, this is not an easy problem as it's basically surface reconstruction. Doing it based on proximity based on what you describe, I imagine it is not going to catch all the possible cases.

To determine distances between the points, you can either do it in POPs with the Proximity POP (it's a long time RFE to have something like this in SOPs), or in VEX, using the point cloud functions.

You're gonna need to build an HDA to do this because it's going to require a whole network. To do your loop, you will need to either use the DOP SOP Solver or some very careful munging using the Copy SOP.

##### Share on other sites

That said...I'm doomed:)

Thanks a lot.

Algorithmic botany paper

Maybe somebody more experienced could shed some light on this super interesting subject.

The effect should be quite easy to achieve if only we had more point sort options.

##### Share on other sites

Nah, I just wanted to mention it's not a like a "one button" thing.

##### Share on other sites

I must be missing something, but there is nothing about attributes in ray SOP ?

My general idea was a bit different, maybe I explained it wrong. I wanted to sort the points without any user input needed.

There is a bunch of points which should be sorted based on their distance between each other so I could feed it to add SOP and create a curve.

21899[/snapback]

Sorry I thought you had a curve through some points and wanted to sort based on the distance to the pre-existing curve.

By the way the "dist" attribute in the ray sop is one of the toggle options near the top. Just for future reference.

For the situation you describe you will problem need to write your own vex function. It might be worth looking at the problem from a different angle so that you can avoid the situation of a cloud of unordered points in the first place. I'll have a look at the paper you link too when I get time and see what is possible.

##### Share on other sites

By the way the "dist" attribute in the ray sop is one of the toggle options near the top. Just for future reference.

21909[/snapback]

oops

Thanks, I'll hold for just a sec writing my own vex sop:)

##### Share on other sites

Just had a look at the paper that you link to, that certainly looks like quite a challenge. Definately looks like a coding job to me.

It does make me wonder if you could do something with particles getting them to flow on the surface and then using a trail sop to connect them, but outside of that it really looks like you'll need to get your hands dirty.

Unless anyone else has any bright ideas...

##### Share on other sites

Just had a look at the paper that you link to, that certainly looks like quite a challenge. Definately looks like a coding job to me.

It does make me wonder if you could do something with particles getting them to flow on the surface and then using a trail sop to connect them, but outside of that it really looks like you'll need to get your hands dirty.

Unless anyone else has any bright ideas...

21923[/snapback]

From my point of view, sorting would be the main problem.

We can extract silhouette points using incidence angle with vex or expressions (I started a thread a few days ago), We can extract points based on surface curvature with measure sop.

Now the points have to be connected, so if only distance based sorting would work, this kind of toon effect should be possible.

The width, alpha, noise etc look all like a piece of cake when we have the base line.

I wonder if you had a look at tomcat cartoon shader for maya:

I heard it's all mel.

Anyway it's interesting and should be achievable with houdini geometry.

##### Share on other sites

They are really nice images, I like this manner of toon shading. Writing a distance based sort in vex is certainly doable but I think it would be way slow. One done in the hdk would work far better.

I can see how you can extract silhouette points but won't that just give you a outline effect like you get with traditional toon renders, how do you get that nice overlapping lines thing happening, that seems like more than just connecting closest points?

Do you have any images of such point clouds?

If you aren't familiar with Hdk I'd be interested in helping out, I'm very interested in non-photo real rendering and this looks like a really nice effect. (as I said already)

##### Share on other sites

I'm absolutely not familiar with HDK nor with any programming language unfortunately:(, so I'd be very thankful for any help.

I'm trying to get myself more technical but since I don't have strictly computer background this is tough.

As a good example of posibilities I took HKtoon.

When we have an outline of sorted points we could create several passes of lines with "add sop/skip every nth pnt", add noise, overlay them and this should give something like a bad sketch look:)

I'll post a short example of technique I have in mind.

It would be more productive if more users shared their ideas since it's in our common interest.

##### Share on other sites

I totally agree, unfortunately most companies put non-disclosure agreements on everyone so people end up re-inventing the wheel all the time in order to keep ahead of the next guy.

##### Share on other sites

you could try attrib transfer after refining the original curve...

also if vops had arrays one could build an array

of points, stepping through connected

points to the last, then assign the array index to a

point attribute that can be used by the sort sop ...

-cpb

rebuild_curve.zip

##### Share on other sites

Unfortunately you came unstuck the same way I did, he doesn't have an original curve to use as reference which makes it all that much more tricky.

##### Share on other sites

Hi peliosis, i had a quick play with a sort by proximity sop. It's nothing that clever but it's a start. I've compiled it for H8.0.383 which is the version I'm using at the moment.

There are 2 problem to over come.

1. How to get the correct start point - at the moment the user has to specify which point to start sorting from. I can't think of any clever solution for this other than pre-sorting in one of the normal axis'.

2. When a line of points curve back on themselves the proximity sort can often take the "wrong" route. I've added an option that tries to stop the direction changing too rapidly but this isn't always the answer.

Anyway it's an interesting problem and one that no doubt will need more work but it's presented here if you want to try it out. I'd be interested in any results or if you can think of a better way to do it or any improvements.

SortProximity.zip

To install it copy the dso directory to yout home directory. You'll have to be using H8.0.383 for it to work I expect.

##### Share on other sites

• 2 weeks later...

http://www.red3d.com/cwr/npr/

...

The toonShade, peliosis mentioned above is death horse already. Maybe at some point later it will become openSource and you can snatch some usefull lines code from there

##### Share on other sites

• 1 month later...

Thank you guys and please excuse me for this extremely long absence, I'm dying out of free time and was forcibly pushed to use 3dstudio (due to vray ofcourse)

Thanks a lot for your help Simon, I'll be back in this subject but have to leave it for another month or so probably.

Peter

PS I'd love to be able to use vray and houdini, maybe in the next 10 years:)

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×