Jump to content

Use variables as channel controllers


Smicksus

Recommended Posts

hello magicians!

I hope someone can help me with a question I have in understanding Houdini better.

So I try to understand how I can make a variable in a wrangle and use that variable's value in a channel.
To try this out for myself I've created a simple assignment:

-Make a wrangle that contains a variable. In this case:

i@myvar = @Time;


-Use @myvar to drive the frequency of a sphere.

In the attached image you can see what exactly I did. And I think I'm doing something wrong in the sphere's channel expression. I used @myvar but the info says "Local variable ''myvar" not found"

Can someone please help me with this challenge?
You get bonus points if you also can teach me how to do this all in one wrangle. (so that I don't have to write a channel expression in the frequency of the sphere, but directly access that in the wrangle itself.) But I don't know if that would be possible :)

Thanks in advance guys! I'm really enjoying my learning progress in Houdini. 
 

neehelp.png

Link to comment
Share on other sites

Hey, 

Your setup is correct but you're only missing one step. In order to reference a detail attribute into a node's parameter you'll have to use the detail function which tells Houdini to read the value of the attribute from a specific input. 

How to type a detail function: detail([int GEO or string GEO PATH], [string NAME OF ATTRIBUTE], 0).

 

In your case that would be the following line: detail("../attribwrangle1", "myVar", 0)

this will read the myVar detail attribute from the wrangle node and pass it into the sphere's frequency parameter.  

Check the houdini docs for more info on how to read attributes: https://www.sidefx.com/docs/houdini/vex/attrib_suite

 

Another point to note, the input for the sphere is used to provide a bounding source (e.g. if you plug a big box into the sphere's input you'll see that the sphere is matching the boundaries of the box). Your attribute wrangle contains no geometry and therefore having it plugged as the bounding source for the sphere would result in nothing, and would make the sphere disappear.

 

Hope this helps! ^_^

  • Like 1
Link to comment
Share on other sites

As Ziyad mentioned, there are some disadvantages to connecting a wrangle into a generator like a sphere. Instead, try adding a single point and copy the sphere to that point, while deriving the frequency value from your detail attribute.

 

sphere_frequency.gif

ap_sphere_attribute_frequency.hiplc

Edited by Atom
  • Like 1
Link to comment
Share on other sites

@Ziyad @Atom

It works! Thank you so much! This opens a lot of possibilities for me :D 

15 hours ago, Ziyad said:

Another point to note, the input for the sphere is used to provide a bounding source (e.g. if you plug a big box into the sphere's input you'll see that the sphere is matching the boundaries of the box). Your attribute wrangle contains no geometry and therefore having it plugged as the bounding source for the sphere would result in nothing, and would make the sphere disappear.

Thank you for explaining this part as well! I was already wondering why my sphere disappeared when I connected a wrangle to it. I thought it had to do with a bad wrangle or something.. But this makes a lot of cense. Does this only occur with generators?
Thank you @Atom for your example-layout on how to go around this. 

Can't wait to make new setups with this information.
Thanks again!

Link to comment
Share on other sites

4 hours ago, Smicksus said:

Does this only occur with generators?

Some other nodes can also accept a bounding source as an input e.g. volume SOP. If you want to know what a node accepts as an input you can just hover over the inputs' tiny circles and it should display a small text telling you what it expects as an input (GIF attached). 

node-input-text.gif.074266cafc914d32414c3237a8590ea3.gif

 

Also not all nodes can function without an input, if you add a new node (e.g. scatter SOP) the tiny input circle will have a red arrow pointing down to indicate that you have to plug an input for the node to work, otherwise you'll receive an error. As opposed to the sphere node where the bounding source is not necessary but rather an optional input. 

 

Glad I could help! And good luck with your future setups ;)

 

 

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...