Question about Normal

   1320   4   0
User Avatar
Member
11 posts
Joined: Aug. 2019
Offline
hello everyone!

In point wrangle, I used the following code

@N *= rand(@ptnum);

Try to make the normal or velocity of the hemisphere(Picture 1)
grow along the original direction and make each size random like grid(Picture 2)
, but in the end The directions would be lost and staggered(Picture 3)
, which seems to only work on a flat grid.

This may be a very new and stupid question, but please give me some advice so that I can continue on the road of Houdini. Thank you.

Attachments:
1.png (254.9 KB)
2.png (574.0 KB)
3.png (293.5 KB)

User Avatar
Member
474 posts
Joined: Feb. 2012
Offline
You can use the adjust vector node for that and just change the length only
Edited by sepu - Jan. 21, 2025 22:57:16

Attachments:
houdini_hKN12qyETE.png (398.6 KB)

User Avatar
Member
9384 posts
Joined: July 2007
Offline
many VEX functions are overloaded, like rand() for example can return single float random number, vector2, vector etc..
Houdini can a lot of times infer this return type from the assignment and if not it will complain

in your case @N is one of the standard attributes and Houdini knows it's a vector even if you don;t specify it as v@N
and because @N is a vector, then Houdini will by default also use vector signature of rand() function in this line
@N *= rand(@ptnum);

meaning that each component of @N will be multiplied by a potentially different random number hence changing the normal's direction
on axis aligned grid it seemingly works since x and z components are 0 regardless

so to get what you want you can do this:
@N *= float(rand(@ptnum));
or maybe cleaner this:
float scale = rand(@ptnum);
@N *= scale;
Edited by tamte - Jan. 21, 2025 22:58:58
Tomas Slancik
CG Supervisor
Framestore, NY
User Avatar
Member
11 posts
Joined: Aug. 2019
Offline
sepu
You can use the adjust vector node for that and just change the length only

There is such a useful node. It seems to be a new node after 18.5. Thank you for your answer!
User Avatar
Member
11 posts
Joined: Aug. 2019
Offline
tamte
many VEX functions are overloaded, like rand() for example can return single float random number, vector2, vector etc..
Houdini can a lot of times infer this return type from the assignment and if not it will complain

in your case @N is one of the standard attributes and Houdini knows it's a vector even if you don;t specify it as v@N
and because @N is a vector, then Houdini will by default also use vector signature of rand() function in this line
@N *= rand(@ptnum);

meaning that each component of @N will be multiplied by a potentially different random number hence changing the normal's direction
on axis aligned grid it seemingly works since x and z components are 0 regardless

so to get what you want you can do this:
@N *= float(rand(@ptnum));
or maybe cleaner this:
float scale = rand(@ptnum);
@N *= scale;

According to what you said, I further verified that the original 【@N】 value multiplied by 【rand(@ptnum)】 produced a random vector value, and the final result was indeed consistent with the value of the normal line whose direction was completely messed up.

Data type is a detail that is easy to overlook for Rookie. Houdini is indeed such a rigorous and professional software. I still have a long way to go in learning. Very happy to have the guidance of you masters here, Thank you for your help and careful explanation Tomas!

May the HOUDINI force be with you!
Edited by GU - Jan. 23, 2025 04:58:43
  • Quick Links