I've been wanting to get into Houdini for a few months now and I finally had some time to dive in. A friend of mine told me to start with a goal in mind and something simple, like a brick wall. And although it sounds simple (I'll have an entire building for you in Maya in minutes 😅) building it procedurally in Houdini requires a bit more more forethought.
So where to start? First thing is think about how I want to set this up. What do I want to be able to control and expose to the user? As this is the first thing I ever did in Houdini I decided to keep the setup simple, so mainly the ability to set the width and height of the wall, as well as determining the scale and color of the brick. And if all goes well add some extras.
After a while I ran into my first problem, how to do the ends? On every alternate row they end on half a brick. I thought about using a boolean, but that felt really crude. Since I start with a line, what I came up with is isolating the two outer points so I can treat them separately using groups. The group for the first point is easy , that's just using 0 (so point number 0) as the Base Group. The last was a bit trickier. Luckily I found out if I can use `npoints("0") - 1` (so number of points - 1) which gave me the last point. But how to get the middle points? Luckily, the ! operator works inside these channels. So using !end_point !start_point as Base Group gave me the third group. +1 for intuitiveness Houdini 👏 For the middle points I additionally created an alternate rows group after the vertical copy and transform that I could then give half a brick offset so it actually looks like a brick pattern.
From there I could just hook up the copy and transform nodes and voila! Well, not quite. Since the half bricks appear every other layer they need to be repeated half of the times of the middle rows vertically. Pasting a relative reference of the total number of copies of the middle group seemed to do the trick. Thing is, since the half brick at the start (or end if you will) already starts one brick height higher means that now there is a half one half brick on top of our wall every other row.
No worries, I'll just subtract 1 from the total number and all will be golden. But now, each other layer I miss half a brick.
So I needed something else. What I noticed was that when the rows were uneven the half brick issue would occur. So I figured a modulus could do the trick. So using a modulus operator the rows would return 0 when the amount of rows is even and 1 if they are uneven which gives me exactly what I needed. My solution looks like this.
ch("../copy_lines_vert_mid/ncy")/2 - ch("../copy_lines_vert_mid/ncy")%2
So far so good. The color was easily fixed with a color node, but I also wanted some hue variation. After looking around I ended on an Attribute Wrangle using some VEX. Luckily, VEX is easy to learn so this was up and running quite quickly. I also used 2 custom channels (hueSeed and hueVariance) so I could expose them later on as I create a Digital Asset from this.
float hue_seed = chf("hueSeed");
float hue_amount = chf("hueVariance");
float r = rand(@ptnum * hue_seed);
v@Cd = fit(set(r, r, r), 0, 1, 0.6 * (1-hue_amount), 1) * v@Cd;
I used the fit command to remap the values to avoid them getting too dark. I tried clamp, but that just kills the lower values removing much of the randomness.
Since things were going smoothly I also wanted was the ability to alter the top of the wall, to create a crumbled look. I looked at the boolean again, but I really wanted the individual bricks to still be visible and the boolean gave me a very smooth, unrealistic look (whatever that means in this context) I settled on creating a volume which moves with the wall's bounding box by creating a group from the points that are inside it and blast those. I started the volume with a line and manipulate it with an attribute VOP.
Also added in a noise value mapped to the brick positions and a seed value.
I made a Houdini Digital Asset out of it and wanted to get it into Unreal, but since I'm using the apprentice version that's not possible. I also wanted to create guide geometry for the crumble volume, but in my digital asset's properties on the Node tab the Guide Geometry is greyed out with the words <Not Applicable> on it. Maybe next time. Here's my final node network:
No comments:
Post a Comment