"Converting" functions
19142 25 0- Soothsayer
- Member
- 862 posts
- Joined: Oct. 2008
- Offline
I'm evaluating Houdini by translating a XSI job into Apprentice. I want to modify points on a surface according to a certain function.
p = p0 − (k/ k) * A * sin(k · p0 − w*t)
and
y = A * cos(k · p0 − wt)
where the bold ones are vectors, and the point p0 = (x0, z0)
How would I “convert” such a function into something Houdini can understand? In XSI ICE we have low level nodes such as dot multiplication for vectors, or nodes that create vectors from scratch (such as k in this example)
I think I can use CHOPs to do this but I'm not sure how to modify the channels according to the above formula. Are there low level nodes for this, or would it be written in expressions. How do I dot-multiply in expressions?
p = p0 − (k/ k) * A * sin(k · p0 − w*t)
and
y = A * cos(k · p0 − wt)
where the bold ones are vectors, and the point p0 = (x0, z0)
How would I “convert” such a function into something Houdini can understand? In XSI ICE we have low level nodes such as dot multiplication for vectors, or nodes that create vectors from scratch (such as k in this example)
I think I can use CHOPs to do this but I'm not sure how to modify the channels according to the above formula. Are there low level nodes for this, or would it be written in expressions. How do I dot-multiply in expressions?
--
Jobless
Jobless
- edward
- Member
- 7743 posts
- Joined: July 2005
- Offline
The closest analogue of ICE from XSI is VOPs in Houdini. I'm not so sure about what those variables are in your post so I just took some liberties with it and came up with the attached file (as a starting point for you anyhow).
After you open it dive into /obj/torus_object1/vopsop1. The network is pretty messy since I just hacked it up quickly.
After you open it dive into /obj/torus_object1/vopsop1. The network is pretty messy since I just hacked it up quickly.
- Soothsayer
- Member
- 862 posts
- Joined: Oct. 2008
- Offline
Thanks, I'll have a look at that later (don't have Houdini on this machine at the moment). As for the variables:
p0 = (x0, z0) is a 2-vector for every point P on the surface giving the x and z coordinates (so, p0, p1, p2, p3, …pn respectively) . I suppose that would have to be split into 2 channels if I use CHOPs?
y is just the y coordinate of a point P
k is a scalar
k is a 3-vector (a direction vector)
A is a scalar
w is a scalar (phase)
t is a scalar (time) (($ in Houdini?)
The whole formula would be applied to every point on a mesh at each frame to create an animated surface.
p0 = (x0, z0) is a 2-vector for every point P on the surface giving the x and z coordinates (so, p0, p1, p2, p3, …pn respectively) . I suppose that would have to be split into 2 channels if I use CHOPs?
y is just the y coordinate of a point P
k is a scalar
k is a 3-vector (a direction vector)
A is a scalar
w is a scalar (phase)
t is a scalar (time) (($ in Houdini?)
The whole formula would be applied to every point on a mesh at each frame to create an animated surface.
--
Jobless
Jobless
- edward
- Member
- 7743 posts
- Joined: July 2005
- Offline
I thought x0 and z0 were also vectors because were in bold. How do you take a 3-vector and do a dot product with a 2-vector? Here's a second crack at translating your equations by just setting the y component to 0 from using 3 vectors for everything. VEX doesn't support 2-vectors intrinsically. It's probably still wrong but you get the idea.
- Soothsayer
- Member
- 862 posts
- Joined: Oct. 2008
- Offline
- edward
- Member
- 7743 posts
- Joined: July 2005
- Offline
- Soothsayer
- Member
- 862 posts
- Joined: Oct. 2008
- Offline
Wow! Thanks Edward, that works beautifully (try a grid)!
But how did you get the time in there? If I dive into angle_rad I see a node called global1. That gets the point positions, right?
I'm actually trying to replicate this:
http://www.ep.liu.se/ecp/028/004/ecp072804.pdf [ep.liu.se]
There's a lot of fluff in that article, so for the moment I'm trying to get (2) and (3) working first.
Changing the values of k doesn't change the wave direction . Everything looks right and logical in the VOPs though.
Are there any xsi-like visual debug tools in Houdini?
But how did you get the time in there? If I dive into angle_rad I see a node called global1. That gets the point positions, right?
I'm actually trying to replicate this:
http://www.ep.liu.se/ecp/028/004/ecp072804.pdf [ep.liu.se]
There's a lot of fluff in that article, so for the moment I'm trying to get (2) and (3) working first.
Changing the values of k doesn't change the wave direction . Everything looks right and logical in the VOPs though.
Are there any xsi-like visual debug tools in Houdini?
--
Jobless
Jobless
- edward
- Member
- 7743 posts
- Joined: July 2005
- Offline
On the global1 node, I had collapsed all its inputs/outputs (by accident ). Click on the “more” output and it should expand. Now you can see that I have “Time” connected to the multiply1 node. The global1 node is supplying “P” for position as well. One can have as many Global Variable nodes as is needed, according to preference.
Changing values of k seems to work for me. Just remember that the second component of it is unused. A better way to do it is probably to leave the third component unused instead. ops:
I haven't had much experience debugging VOP networks. I think one way to do it is to use Add Attribute VOPs to output intermediate values to Cd (color), or to some other named attribute. If not using “Cd”, then we can add custom attribute visualization display options. There is also the Print VOP that one can use as well.
A critical difference with VOPs and ICE I think is that VOPs actually just a GUI on top of the VEX language. Such low level nodes don't scale up in complexity as well as actual code. So past a certain point, it will be better to just do it in the VEX programming language rather than in VOPs. The nice thing of course is that you can look at the generated VEX code at any point in time.
Changing values of k seems to work for me. Just remember that the second component of it is unused. A better way to do it is probably to leave the third component unused instead. ops:
I haven't had much experience debugging VOP networks. I think one way to do it is to use Add Attribute VOPs to output intermediate values to Cd (color), or to some other named attribute. If not using “Cd”, then we can add custom attribute visualization display options. There is also the Print VOP that one can use as well.
A critical difference with VOPs and ICE I think is that VOPs actually just a GUI on top of the VEX language. Such low level nodes don't scale up in complexity as well as actual code. So past a certain point, it will be better to just do it in the VEX programming language rather than in VOPs. The nice thing of course is that you can look at the generated VEX code at any point in time.
- edward
- Member
- 7743 posts
- Joined: July 2005
- Offline
- rdg
- Member
- 401 posts
- Joined:
- Offline
- Soothsayer
- Member
- 862 posts
- Joined: Oct. 2008
- Offline
- edward
- Member
- 7743 posts
- Joined: July 2005
- Offline
- edward
- Member
- 7743 posts
- Joined: July 2005
- Offline
- edward
- Member
- 7743 posts
- Joined: July 2005
- Offline
- Soothsayer
- Member
- 862 posts
- Joined: Oct. 2008
- Offline
- Soothsayer
- Member
- 862 posts
- Joined: Oct. 2008
- Offline
- edward
- Member
- 7743 posts
- Joined: July 2005
- Offline
- Soothsayer
- Member
- 862 posts
- Joined: Oct. 2008
- Offline
OK. I've added some stuff and it works nicely now.
I still have some question about the nodes.
1) How can I change the input and output names of nodes such as “multiply” and “subnet”. They have default names such as “input1”.
2) I want to drive some of the parameters from outside the vopsop. For example D (depth) should get its values from the distance of a wave-surface-point to the ground (box in my example scene). I guess the “ray” node does that but how do I get it to work inside the vopsop?
3) Adding several copies of the vopsops sequentially one after the other doesn't sum up the waves correctly. I want to try it “in parallel” with something akin to the math node in CHOPs. Can it be done?
I still have some question about the nodes.
1) How can I change the input and output names of nodes such as “multiply” and “subnet”. They have default names such as “input1”.
2) I want to drive some of the parameters from outside the vopsop. For example D (depth) should get its values from the distance of a wave-surface-point to the ground (box in my example scene). I guess the “ray” node does that but how do I get it to work inside the vopsop?
3) Adding several copies of the vopsops sequentially one after the other doesn't sum up the waves correctly. I want to try it “in parallel” with something akin to the math node in CHOPs. Can it be done?
--
Jobless
Jobless
- rdg
- Member
- 401 posts
- Joined:
- Offline
- edward
- Member
- 7743 posts
- Joined: July 2005
- Offline
Soothsayer
1) How can I change the input and output names of nodes such as “multiply” and “subnet”. They have default names such as “input1”.
It's not possible for nodes such as “multiply”. For subnets, if you click on the parameter of the “suboutput1” node then you can rename the outputs. Note that I just noticed a UI bug where the old values aren't visually erased until you dive up and down again.
2) I want to drive some of the parameters from outside the vopsop. For example D (depth) should get its values from the distance of a wave-surface-point to the ground (box in my example scene). I guess the “ray” node does that but how do I get it to work inside the vopsop?
This is easily done via point attributes. Inside the VOP network, you can use the Import Attribute VOP. I have attached a simplistic example file.
3) Adding several copies of the vopsops sequentially one after the other doesn't sum up the waves correctly. I want to try it “in parallel” with something akin to the math node in CHOPs. Can it be done?
As what rdg said, to do it sequentially, you need to add your result to the original P value. Otherwise, you can use a Point SOP to sum them in parallel. Another approach is to add your result to the second input of your VOP network. Inside the VOP network, use an Import Attribute VOP with “P” as the name, “Vector” as the type“ and specify 1 as the ”OP input index".
Other ideas
A key advantage to using VOPs is that you're actually writing a geometry shader. So this means that with some tweaking when you're done, you should be able to reuse the VOP network as a displacement shader network later on so that that the waves can be displaced at the micropolygon level.
I think the Houdini Ocean Toolkit [forums.odforce.net] does this.
-
- Quick Links