Propagating point creation with VEX

   2880   8   1
User Avatar
Member
14 posts
Joined: Jan. 2016
Offline
LATEST WIP UPDATE:




Debugging

- Fixed scaling for anything outside the unit circle.

- Fixed curve framing with extreme angles by using dihedral to minimize rotation (thanks to Entagma for the theoretical insight on this one)

- Addressing tiny falloff value differences with a statistical variance check and a threshold parameter. (e.g. when the sample points are in a circle).

- Floating-point precision fix.

- Post carve ‘curveu’ recalculation takes care of the vertex colors ramp now.



Features

- Added point sampling mode switch (cone cap or cone volume)

- Added twist control

- (Obsolete since H18) Added per connected mesh UVs using Toraku's “Get correct uvs with a sweep sop” fix - http://www.tokeru.com/cgwiki/index.php?title=Houdini#Get_correct_uvs_with_a_sweep_sop [www.tokeru.com]

- “Listening” for N and iteration attributes.

- Using the new sweep sop now.




———————————————————————————————————
Hi folks,

How would you go about adding points in a propagating manner in VEX. Here's what I mean:

- Start with several incoming base points, each with an up vector.

- For each one, add a new point somewhere along its up vector.

- Calculate a new up vector by subtracting base positions from new point positions and setting the new point up vector to the result

- Add the next new point somewhere along the previous point's up vector



So, I called it propagating, because every next point in part defines the following.

I think I'm on the right track here, but my gut's telling me I'm missing something.



vector up = point(0, "up", @ptnum);
vector currentPos = point(0, "P", @ptnum);
vector newPos = {0,0,0};


int pts[];

for(int i=0; i<@numelem; i++) {
    append(pts,i);
}


int iteration = chi("iteration");

for(int j=0; j<=iteration-1; j++){
    
    newPos = currentPos+up;
    int newPoint = addpoint(0, newPos);
    
    setpointattrib(0, "up", len(pts)+j, normalize(newPos), "set");
    currentPos = point(0, "P", len(pts)+j);
    up = normalize(newPos-currentPos);
    currentPos = newPos;
}

Where do you think I'm wrong here. What would you do? Cheers!
Edited by Haki - Jan. 18, 2020 03:30:24

Attachments:
propagating_points.gif (336.7 KB)
stipules_gen_gumroad_poster.png (220.3 KB)

3D Generalist
https://hristo.one [hristo.one]
User Avatar
Member
14 posts
Joined: Jan. 2016
Offline
Some corrections here:

vector up = @up;
vector current_pos = @P;
vector new_pos = 0;

int samples = chi("samples");
float offset = chf("offset");


for(int i = 0; i < samples; i++){


new_pos += current_pos + up * offset;
int new_point = addpoint(0, new_pos);

up = normalize(new_pos-current_pos);
setpointattrib(0, "up", new_point, up, "set");

current_pos = point(0, "P", new_point);
}

I didn't write in the post above, that I intended to later randomize the up vector direction for every new point and thus get a non-linear propagating pattern. I want to achieve a sort of (and I suspect that's not the right term here) parent-child behavior between every point and the next in line (something like tentacles constructed by points propagating in random directions). That's the reason why (in my head at least), calculating a new up by subtracting current_pos from new_pos and setting that at every sample is important.

Except, and this is probably going to seem totally dumb… at sample 2 it falls apart. Up is no longer pointing where I'd expect it to. I bet this has something to do with the last line current_pos = point(0, “P”, new_point);

It appears at sample 2, the up direction is pointing away from the world origin, and not away from the points at sample 1. I feel like I'm missing something so basic…



Edit:
Ok, getting somewhere with random vectors:

Edited by Haki - Dec. 3, 2019 08:23:20

Attachments:
propagating_points_with_rand_dir.jpg (499.3 KB)
rand_dir_propagating_points.hiplc (571.6 KB)
drawing_board_time.jpg (42.2 KB)
propagating_points_with_rand_dir_draw.jpg (269.2 KB)

3D Generalist
https://hristo.one [hristo.one]
User Avatar
Member
14 posts
Joined: Jan. 2016
Offline
A quick update:



I can't wrap my head around how to gain manual control over the rand vector for each sample yet. Any ideas?

Also, connecting the points in order seems to be a challenge now because of this point number pattern 0,4,5,6…; 1,7,8,9…; 2,10,11,12…

Maybe building arrays for each ptnum. 0(0,4,5,6); 1(1,7,8,9) so on..?
Edited by Haki - Dec. 4, 2019 05:35:45
3D Generalist
https://hristo.one [hristo.one]
User Avatar
Member
5 posts
Joined: March 2019
Offline
I don't even know where to start to help you, but awesome work until now! Thanks for sharing, will study on!
User Avatar
Member
14 posts
Joined: Jan. 2016
Offline
Cheers, @demoncase

Ta-da! I got the point arrays exactly in the correct order for the point number pattern I was getting.



Alright, it's going to be smooth sailing from here on… (doing a little dance) Wait, what!? Addprim didn't do what you imagined? Documentation, here I come.

(Edit)
What's the correct way to pass those point number arrays to the addprim function to get a polyline for each one?
Edited by Haki - Dec. 8, 2019 07:19:16

Attachments:
propagating_points_with_rand_dir_prim.jpg (667.3 KB)

3D Generalist
https://hristo.one [hristo.one]
User Avatar
Member
14 posts
Joined: Jan. 2016
Offline
Eureka! (No need for point arrays after all…)



So, from what I originally intended to be a grass generator… it will be a multi-purpose generator (including the effect on hair that electrocution has according to popular cartoon depictions)



Still to figure out a way to control the up angle at every sample… and to orient the points correctly based on the starting points (polyframe the prims I guess…)

Edit- With some finetuning below:

Image Not Found
Edited by Haki - Dec. 10, 2019 03:57:16

Attachments:
propagating_points_with_rand_dir_prim_eureka.jpg (521.2 KB)
rand_dir_propagating_points_2.hiplc (585.7 KB)

3D Generalist
https://hristo.one [hristo.one]
User Avatar
Member
14 posts
Joined: Jan. 2016
Offline
Hey folks, back with an update here, I took care of the curve framing:



Thanks to Entagma's Parallel Transport tutorial I understood the core concept here. I adapted it to my curves generator. I tried 2-3 alternatives, including the slideframe() function and the dihedral()*v0. Seems I got the best result by crossing vectors only. The slideframe and the dihedral seemed somewhat off, probably because I didn't do something right.

Here's the file if you wanna give it try:
Image Not Found


With width and pscale attributes. Can be rendered as hair/fir now.

Edited by Haki - Dec. 17, 2019 08:59:26

Attachments:
rand_dir_propagating_points_3.hiplc (609.9 KB)

3D Generalist
https://hristo.one [hristo.one]
User Avatar
Member
14 posts
Joined: Jan. 2016
Offline
Debugging

- Fixed scaling for anything outside the unit circle.

- Fixed curve framing with extreme angles by using dihedral to minimize rotation (thanks to Entagma for the theoretical insight on this one)

Features

- Added point sampling mode switch (cone cap or cone volume)

- Added twist control

- Added per connected mesh UVs using Toraku's “Get correct uvs with a sweep sop” fix - http://www.tokeru.com/cgwiki/index.php?title=Houdini#Get_correct_uvs_with_a_sweep_sop [www.tokeru.com]


Some practical results with it here (and one of my first ever tutorials, haha):


Give it a try and if you have suggestions, feel free. Cheers!
Image Not Found
Edited by Haki - Jan. 2, 2020 02:50:26

Attachments:
grass_n_stuff_gen_18_4b.hiplc (1.8 MB)

3D Generalist
https://hristo.one [hristo.one]
User Avatar
Member
14 posts
Joined: Jan. 2016
Offline
Here's the beta. Give it a try (it's free). https://gum.co/SOpPT [gum.co]

Attachments:
stipules_gen_gumroad_poster.png (220.3 KB)

3D Generalist
https://hristo.one [hristo.one]
  • Quick Links