Here is the video from the lecture Seth gave us on Thursday. Enjoy Thanksgiving break and working on your villages!
Learning Adventures in Houdini
Saturday, November 21, 2015
Thursday, November 19, 2015
All About HScript 1
INTRO:
Seth pointed out this great resource about expressions and HScript. It is a powerful way to get the flexibility you will need for the village project (or any final project) in the scripting class. Here is the link:
http://www.sidefx.com/index.php?option=com_content&task=view&id=1500&Itemid=305
It contains 18 videos.
I watched and summarized the most important parts with screenshots. This will help because you can better know which tutorial to watch to help you. It's a work in progress, I may not have all 18 done yet.
VIDEO 1: Introduction to Attributes, Variables, and Expressions
Skip first 6 minutes (talks about setting key frames for values)
Any legal math expression that you can type into a calculator, you can type into the value box in Houdini
In the following examples, you can ignore the ` character. It is just used in text boxes and we rarely work in text boxes.





To learn more about modulus check out the bottom of this blog post. In short, it returns the remainder.
And you can also get into order of opperations using parentheses.
Take away: Your tools for doing calculator math in Houdini are + - * / ^ % ( )
What About Comparisons?
This is where HScript comes in handy. You can do comparisons such as less than <
greater than >
not equal to !=
greater than or equal to >=
and others using simple h script.

For example, if you put down a switch node between a circle and a sphere you can tell the switch node exaclty when to switch using an expression$F > 1
RESULT: At frames 0 and 1, the tube will be output
At framse 2 and above, the sphere will be output
The dollar sign $ just means that a built in houdini variable is being used. You can look up which other variables are available to use in the help section of Houdini.
Did you know you can have more than one condition?
You can also use the "or" operator and the "and" operator.
OR = ||
AND = &&
So what if I only want an input inbetween frame 6 and 44?
Then I can use the && operator to select an input when the frame number is greater than 6 AND less than 44.
More relevant example
We probably won't be using frame number in our village building assignment, however, the same principle applies. What if you have two models of roads and you want to switch between them if the user increases the road width above a certain value?
You could do something like this:
If the road width is greater than 66, switch geometry input
Translated to computer talk:
ch(../roadWidth) > 66
End of Video 1
Friday, November 6, 2015
Summary of Seth's 1 hour video Part 2
Part 2
Starting at about 36 mins in
1. Adding Sliders
So now that you can get variation using stamping and random variables, how do you add sliders to allow the artist to control your tool?
In the end, it is the same principle, but it requires some creativity with referencing (you already know how to do that).
In the picture below, we are in the context of the castle building node "Castle_Wall". The parameters (or sliders) we added are the top four. Remember that the sliders we are adding are being added to the node that builds the whole castle. So these will change the whole look of the "village" rather than modifiying each individual building alone.
Go to the node you want to modify and select "Edit Parameter Interface"
Add a parameter by selecting the type of data type you want it to be. Float is a great one because it is a number that isn't limited to whole numbers (that would be integer)
Set the name and label (label is what you see, name is what you will type when referencing) in the parameter tab. You can also add default values as shown in the picture below.
Now that these parameters exist, go back to your copy node where you were working on stamping, and reference the parameters (our new sliders) in the stamping function.
Here Seth has the following code:rand($PT) * ch("../maxwidth")
rand($PT) * ch("../maxheight")
Think about what this does, (or watch it at 35:38) as Seth moves the slider maxheight that he just created, all the buildings will go up or down.
cool, so with that function we can now adjust the height and width of all buildings, or rather, we can adjust the width and height of the whole village.
What about variation? What if we want a "new" random height and width of all the buildings in the village?
Look at the very fist picture in this post. You will notice height varation and width variation variables. Go ahead and make those. Remember, the naming is arbitrary, the referencing is the thing that really matters.
Now back to our rand function. Before it might have looked like this: rand($PT) * ch("../maxwidth")
If you were to add 1 to $PT all the buildings random values would change. rand($PT +1 ) * ch("../maxwidth"). Instead of adding 1, why not reference a value which the artist can easily change like the slider variable we just created?
now our function looks like this ^
Now as you change the "variation" slider, the buildings widths randomly change every time you move the slider. You can keep moving until you get a variation you like. Pretty sick. (watch @ 38:40)
2. Putting limits on the variable
I probably don't want my buildings to be height 0 and I probably don't want them to be 500 either. I can edit my parameter and add a range.
3. Using python with Houdini
Everything we learned about Python in Maya applies to Houdini. We can even use Houdini's library of functions they have already written. Learn about them here:
For example, what if you wanted to control you random expression a wee bit more. You want a couple buildings to be even higher than the others like the picture below.
To do this, open up the expression editor by right clicking the value box, then selecting "Edit Expression." Or pressing "Alt e" If you don't open up the editor, you can only type in one liners. Gross.
Also, remember to change the language to Python as shown below
You know the language has been changed when the box changes colors to red. Yuck, that makes me think it's an error.
import hou <- Needed to access houdini's built in functions
import random <- Needed to use Python's built in random functions
heightvariation = hou.ch("../heightvar" ) <- We make a variable that get's the reference value
pointNum = hou.expandString( "$PT" ) <- To make every fourth point different, we need it's value
pointNum = int ( pointNum) <- Oops, houdini returned it to us as a String, not an int. So we convert it.
finalValue = 0 <- We declare finalValue because we need it to exist beyond our "if, else" block of code
if pointNum % 4 == 0: <- If pointNum is a multiple of 4, enter our if statement.
finalValue = (random.random() * heightvariation) + 6 <- make it bigger! Use a random value
else:
finalValue = 3 <- make other buildings size three. I would personally do finalValue = heightvariation
return finalValue
4. What the %?
% is called modulus. "Mod" for short. All it does is return the remainder.
4%4 = 0
5%4 = 1
6%4 = 2
7%4 = 3
8%4 = 0
9%4 = 1
10%4 =2
and so on... Notice how it repeats
So you can use it to get multiples of a number. If you do X%4 == 0, every time X is a multiple of 4 it will equal 0 and thus enter that block of code.
5. The End!
UGH, that was painful. But now I know this stuff pretty well. Just ask me in person. haha
Thursday, November 5, 2015
Summary of Seth's 1 hour video Part 1
- Lock option on Nodes
Potential Problem: When you share that hip file (houdini file) with anyone else it won't work because your node is referencing the geometry file.
Solution: Lock the node. That will essentially "bake" the geometry into the node and it will work on any computer. Right click -> lock node
Create variable that will give you the random range you want. The name is arbitrary. You make it up. Seth called it thickness. Notice he is currently using rand($pt). This will give you a random number between 0-1. So when you do it a better solution would be rand($pt)*5. This is Seth's solution later. Stuff You Don't Need to Read:$pt is a local varible called point number. In our case we are "seeding" the random function with point number. This is useful because no two point numbers are the same.
2. You can add referenced parameters
The second example shows two chanel references being added together
3. Stamping
The current network is a tower being copied onto a line with a couple points.
Inside the copy node there is stamping.
Make sure to turn on the stamping.
Create variable that will give you the random range you want. The name is arbitrary. You make it up. Seth called it thickness. Notice he is currently using rand($pt). This will give you a random number between 0-1. So when you do it a better solution would be rand($pt)*5. This is Seth's solution later. Stuff You Don't Need to Read:$pt is a local varible called point number. In our case we are "seeding" the random function with point number. This is useful because no two point numbers are the same.
Now, go to the parameter that you want to be random (in our case it is tower thickness) and reference the stamp parameter by typing the following in the box:
stamp("path name to copy node", "name of parameter in copy node", default value)
Seth uses -1 as the default value because if something goes wrong, he will know immediately because there won't be any towers there anymore!
If you have checked the stamping box, and made sure your rand function evaluates to something greater than 1, and referenced your stamp variable you created using the stamp command, then you are good to go!
4. The Problem With Random Seeds
Let's say you have two "stamp" variables you created. What if you type in rand($pt) * (a number) into both of them? See picture below...
Problem: It's not actually "random." Both thickness and height are getting the same number from rant($pt). Notice how thickness seems related to height. That's because it is. Each time you go throught our "for loop" of copying, the function rand($pt) WILL give you a new random number because $pt is changing. However, this rand($pt) function is in the SAME iteration of the loop and it is using the SAME value for $pt. So it will always return the same number.
Solution: Give your second rand function a new seed. So somehow it needs a unique number from it's partner. Easy solution: Just add a number inside the parentheses.
Now notice how height is no longer related to thickness. We are giving two different seeds to our rand function. So now they return different numbers.
End Part 1
Digital Asset 1.0
The network we will build will be pretty powerful, but if we can't share that network with others then that severely limits us. To make it into "tool" we make it something called a digital asset. A digital asset takes the node network we have created and represents it as one node, then we choose which parameters we want to promote to show up on the interface.
Here is a link to a the tutorial
http://www.sidefx.com/images/stories/blogs/houdini9_blog/NodeWorkflow/procedural_forest.mov
The digital asset part is the last couple minutes.
Here is a link to a the tutorial
http://www.sidefx.com/images/stories/blogs/houdini9_blog/NodeWorkflow/procedural_forest.mov
The digital asset part is the last couple minutes.
Let the Adventure Begin....
As suggested by the most interesting man in the world: Jeremy Dance
This is a blog to share our findings in Houdini. It is a haven for asking questions and posting things as we find them in.
Our dear friend, Seth Holladay has been generous enough to give us some content to start the blog out:
Intro to Houdini:
Expressions
Python in Houdini:
This is a blog post that summarizes the important parts of Seth's second tutorial:
http://byuhoudini.blogspot.com/2015/11/summary-of-seths-1-hour-video.html
Happy learning everyone!!
Please don't hesitate to post!
This is a blog to share our findings in Houdini. It is a haven for asking questions and posting things as we find them in.
Our dear friend, Seth Holladay has been generous enough to give us some content to start the blog out:
Intro to Houdini:
Expressions
Python in Houdini:
This is a blog post that summarizes the important parts of Seth's second tutorial:
http://byuhoudini.blogspot.com/2015/11/summary-of-seths-1-hour-video.html
Happy learning everyone!!
Please don't hesitate to post!
Subscribe to:
Comments (Atom)

























