How to normalize distance within a point cloud?

   2144   1   0
User Avatar
Member
49 posts
Joined: 9月 2013
Offline
Hello all,

I hope someone knows the answer to this.


1: I have a horizontal line aligned to Z-axis.
2: I create a tube out of it using the polywire node.
3: Using mountain sop using the defaults I create some noise on it(almost looks like periodic noise) and I just reduce the frequencey
of noise by increasing the Element size parm, nothing fancy.
4: Using points from volume node, I scatter some points inside this noisy tube.
5: I calculate the near distance, from the line to the point cloud like so:
int nearpt = nearpoint(1, @P);
vector nearpos = point(1, ‘P’, nearpt);
f@near_dist = distance(@P, nearpos);
6: Now that I have the distance, what I want to do is normalize this distance. Which means creating value of 0(from the horizonatal line) to 1(outer edge/periphery of the noisy tube).
7: To “normalize” this value of f@near_dist I use the fit function, fitting f@near_dist from its min_value to it's max_value to 0-1.

This here is the problem. I don't seem to get proper distribution of values from 0-1 within this point cloud. The value on the outer edge of the noisy tube is anywhere from approx 0.1-0.98. I need those values to be 1 so that the point cloud has values from 1(from outer edge) progressively decreasing to 0(which is the core of the point cloud/line). Imagine if you take a cross-section of this tube in any section, the value should always go from 0(in the center) to 1(outermost radius), no matter where the cross-section is.

I also tried using sdf's. But I can't have an sdf so high-res as to give me an accurate gradient within the point cloud.

So my question is what is the way in which I can achieve this normalization of the f@near_dist?

Looking forward to your answers, I have attached a file for your reference.

Cheers!

Attachments:
normalize_dist_v001.hipnc (170.8 KB)

User Avatar
Member
4516 posts
Joined: 2月 2012
Offline
Hi,

That's because you are normalizing across all points. You need to normalize each cross section separately. I made some changes to achieve that. Unfortunately Attribute Promote can't promote point pieces separately, they have to be primitives. So you have to loop through each cross section or write some VEX code to do the promotion (slow).

Attachments:
normalize_dist_v001.hipnc (190.5 KB)

Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]

youtube.com/@pragmaticvfx | patreon.com/animatrix | animatrix2k7.gumroad.com
  • Quick Links