"Converting" functions

   19142   25   0
User Avatar
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?
--
Jobless
User Avatar
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.

Attachments:
iceconvert.hip (60.4 KB)

User Avatar
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.
--
Jobless
User Avatar
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.

Attachments:
iceconvert2.hip (83.9 KB)

User Avatar
Member
862 posts
Joined: Oct. 2008
Offline
edward
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?

Ah! k is a 2 vector too. Sorry, mistake! ops:
--
Jobless
User Avatar
Member
7743 posts
Joined: July 2005
Offline
Ah, that explains everything. Anyhow, just pretend the k parameter is a 2 vector that only uses the first and last component then.
User Avatar
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?
--
Jobless
User Avatar
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.
User Avatar
Member
7743 posts
Joined: July 2005
Offline
PS. I don't have time to look at the pdf but shouldn't k be normalized?
User Avatar
Member
401 posts
Joined:
Offline
there is also a printVOP.
Not really visually unless you add maybe some fancy ASCII art
this is not a science fair.
User Avatar
Member
862 posts
Joined: Oct. 2008
Offline
Actually, none of the variables seem to have any effect. I am changing the values in the Parameter window, scrolling down to the “Numerical Defaults”.

I also get the Houdini Console popping up with “Error reading SVG:”

Sorry for me being so stupid!
--
Jobless
User Avatar
Member
7743 posts
Joined: July 2005
Offline
Ah, no, because you're changing the default values of the VEX “shader”. To change the value you want to do it at the SOP level. So go up one level from where you are.
User Avatar
Member
7743 posts
Joined: July 2005
Offline
Here's a pic…

Attachments:
vopsop.jpg (92.5 KB)

User Avatar
Member
7743 posts
Joined: July 2005
Offline
Recall, that a VOP SOP network can be re-used with different parameter settings, on different geometry.
User Avatar
Member
862 posts
Joined: Oct. 2008
Offline
Thanks, I'll try that when I get home. Takes a while to get my head around this!

That's very useful to have the variables automatically exposed on the SOP level.
--
Jobless
User Avatar
Member
862 posts
Joined: Oct. 2008
Offline
I tried to add some nodes into the network to further define some values. The nodes are in the vopsop1 and are called gamma, k_mag, and w_noDepth. But the nodes make the whole thing not work.

What is going wrong? If I delete them it works again.

Attachments:
problem.hipnc (103.6 KB)
screen.jpg (22.2 KB)

--
Jobless
User Avatar
Member
7743 posts
Joined: July 2005
Offline
When I loaded your file, I got warnings on the nodes. If I middle-click on one of them, the VEX language errors show up.

The problem is that you've created a parameter called “2pi”. However, parameters in VEX can't begin with numbers, so if I change it to “pi2” instead, then everything works.

Attachments:
voperrors.jpg (81.9 KB)

User Avatar
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?

Attachments:
problem1.jpg (5.1 KB)
basic.hipnc (232.0 KB)
prob3.jpg (18.6 KB)

--
Jobless
User Avatar
Member
401 posts
Joined:
Offline
For 3: You can either use a pointSOP or another VOPSOP to add/mult/whatever both VOPSOPs.
In case of the pointSOP you're referencing the positions from the second input using $TX2, $TY2 and $TZ2.
In a VOPSOP you can use the importAttributeVOP to read the positions.
this is not a science fair.
User Avatar
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.

Attachments:
basic2.hipnc (250.4 KB)

  • Quick Links