Website powered by

Houdini blog #3: Quick bend

General / 19 March 2019



This week there I have made my own version of the bend node (sop). I had the idea for it some time now, but never made it. So the node will automatically bend any geometry is gets as input. Since I'm doing a lot of modelling in Houdini at work this could be very useful. The issue I have with the default bend node in Houdini is all the setup work you will need to do. 

I'm also started preparing for the Everything Procedural Conference. Super proud to be a speaker at the event. The talk will be about how Houdini is used in an indie studio.

Quick bend

The node will automatically find the size of the object you plug in there and bend it. To make this yourself, I started with the started bend node. At the beginning I was going in there and start adding lines of VEX. But later I found that it was better to use expressions in the started bend node.

This is a gif of the result, Alien panel is from Substance Source. Next week there we be a polish pass on it.

Bounding boxes

The first thing to do here is getting the bounding boxes of the object you want to bend. In VEX you would type

 getbbox_min(0); //VEX

 You will need this if you decide to adjust the wrangle of the bend node.

You can also just do it with expressions and the line can be used in a variety of nodes/sops.

bbox(0,D_XMIN) //expression

This will return the smallest point on the X-axis. Based of course on what the axis you type you will get different results. Similar versions of these are XMAX and XSIZE. Like I just mentioned you can use this in other nodes as well, for example use it in the duplicate node, where you automatically detected the offset to copy the next model.



Export handler

Something that was interesting is making custom handlers. This is very useful if you are making HDA’s and have interactions with the viewport. For the quick bend there is a handler that controls a direction of bending. The easy way of creating these handles is by right clicking on an already existing handler and click export. This video shows how to do it. The more manual way is by going in the parameter interface and go to the handler tab. Here you have the option the create a variety of handlers. You will also need to assign parameters to the handlers, so the handler knows what data to read and write.

https://www.youtube.com/watch?v=J8hwiYkBnQc

Get point attributes

As last a small line of code that came handy was the point expression. With this you can get the value of an attribute. If you make your own attributes and you want to access this in a transform sop, you will not type @MyAttribute. This makes sense because attributes are information that is stored on points, prim,.. So by doing a @MyAttribute in a transform sop, the sop doesn’t know what point to look at as each point in the model can have a different @MyAttribute value.  Attributes are not variables that you call everywhere. By using the “point” we can access the attribute of a specific point number.

point(0,0,"example",0) //fill this in the scale of the transform sop

Thank you so much for taking a look and a read at the blog!
Hopefully see you next time.


If you have any thoughts or feedback feel free to share it.


  

A Houdini Blog #2: VEX part 2

General / 11 March 2019



Intro

Last post was about the basics of VEX and doing some exercises, this post will be more fun because some stuff will be destroyed. This week the inspiration came from David Kahl. On his Youtube Channel he has amazing videos on Houdini and tutorials on how to make it. The video that got my attention this week was his video of VEX driven workflows. This video was a presentation during the EUE event. The video shows a fractured model that is controlled with VEX. By using a point cloud, you can select the fractured pieces that needs to be influenced. After following the video you will have a nice setup to play around with it more. Like you can try plugin in different models or adjust the code to create your own effect.


Also looked up more information on attributes in Houdini. It is important to know what they are and what they can do. A good video on it was from Rohan Dalvi. What is also good to know is the difference between attributes and variables.

Fractured pieces and VEX

Fracturing the pig


With the setup from the video that was mentioned in the beginning. By playing around with it you can get interesting results. By adjusting the code in the if-statement the code you can get some cool looking effects. Using point clouds is something that was here very useful.

To create a point clouds you will need this function pcopen. Example 

pcopen(1,”P”, @P , ch(“range”), 1);

To use this function you will need have to give it some information. First is geometry to look at, so by setting this to 1. It will take the second input of the wrangle code. The “P” is to read the point information and @P is the position of the points. Next is setting a range to how far the points have to look around itself. So every point that is in the range/radius will be stored in the point cloud. As last you will set how much points you will allow to be added in the point cloud.

Further with functions you will be able the get the data out of the point clouds. Like pcnumfound( ) which will return the amount of points in a point cloud.

Exporting the pig

There was also some curiosity that I had to see if it is possible to get it in game engine. Ended up with uploading it to Sketchfab as test/proof that you are able to use it in different software. The export itself was quiet easy by using the RDB to FBX node. (RDB stands for Rigidbody.) However this node is only available to you if the Game Development Tools are installed. I highly recommend you installing this. SideFX did an awesome job on these nodes.

Photo of the node that you will need for exporting.


To install the game dev tools go in the Houdini shelfs and look for the game dev tools. Next click on the Update toolset and a menu will pop up asking you to install them.

What you have to know is that each piece will be a bone! There is a node in the game dev tools that is called Destruction cleanup. This will group fractured piece together to use less bones. (Note I have not tested this on the model)


Destruction tool

Later in the week the idea was created to make a fast destruction tool. This tool destroys an object real time with no need of simulation, which means you get instantly the result of a broken mesh. The idea also came partially because a friend of mine was making an environment with a lot of destruction, so this tool could possible saving him tons of time. Quickly there was the first prototype version of the tool. By using a setup that was similar of the tutorial that was mentioned in the beginning.

Here is the tool working in Unreal Engine 4. Also here is the Artstation link for more gif and photos of the tool.

The setup is small and uses a few nodes. The wrangle has 3 inputs a fractured model of choose, a single point (will be used for point cloud) and a plane where the debris should be laying on. Start by creating a point cloud of the single point. When the single point is closer to the model it will select more points of the fractured model. The points that are in the range( the point cloud) will be used as debris. By using an if-statement you are able to change the position of the pieces (use pcnumfound in the if-statement to see if points are in the point cloud or not).

To place the points that are in the point cloud on the grid we will make use of the parametric UV. If you visualize this on a plane it will look like this. parametric UV was also a topic of the Joy of VEX that I followed.

To make it more clear compare this result with the texture coordinate node of Unreal Engine 4. This is representing the uv or the red and green channel. Note that a parametric uv is made for each poly/face. So if your grid has 9 polygons you will have 9 parametric uv’s (you will see it tiling 9 times). Now to place the models on it you can do that by typing the following. (Setup for this is a wrangle with in the first input a point and in the second input a plane)

vector uv = curlnoise(@P*chv("Scale")+@Time);
uv = fit(uv, -1,1,-1,1);
uv += {0.5,0.5}; //place in center
@P = primuv(1,'P',0,uv);

Start with creating a vector uv and give it some random noise that can be changed with time. Then control the value better with doing a fit so it stays on the plane. Next is centering the values by adding .5.  Finally the last piece of code will place the points on the plane.

For integrating this piece of code in the destruction tool will be in the if-statement. So when a point is in the point cloud add noise to the point and then use primuv to place it on the plane. As result you now have debris laying around. Of course you will need to fine tune the code a bit more as it will be to random placed by the noise. One thing you can do is calculate the direction of the single point that creates the point clouds. This will result in debris that will have a direction.


Thanks so much for taking a look and a read at the blog! I hope you enjoyed this weeks blog post.
Hopefully see you next time.


If you have any thoughts or feedback feel free to share it.


A Houdini Blog #1: Starting with VEX

General / 03 March 2019

Intro

Hey, I’m Simon Verstraete. Currently working as Environment and technical artist at eXiin. At eXiin we are making Ary and the secret of seasons (in the game you can control the seasons in real time). I have been using Houdini for about a year now and this all started as a simple graduation project at school (DAE). At the time this video convinced me to start learning Houdini.

https://vimeo.com/210679269


What is the problem/What am I going to do

After the House generator I felt that going deeper in VEX will  be the next step in Learning more about Houdini. In the House generator there is room for improvement and VEX will help with solving complex systems. Instead of using a lot of nodes to fix an issue VEX could solve it with a few lines of code.

As background a few years ago I did some programming in C++ and a bit of C# with unity. But that was sometime ago and the focus for me was more on the art side or node based programs. So with this blog we will start with a basic knowledge of Houdini and very basic knowledge of coding/VEX.

If you are reading this and you have resources or information that could help people out, shared it in the comments and thank you!


The Power of VEX  

What is VEX

VEX is an efficient language in Houdini that is used to make custom nodes and writing shaders. The language itself is not an alternative to scripting and it is loosely based on C. 

By placing the wrangle node in your network you have a node that has a big textbox where the VEX code will be in. By default the node will run over all the points in the first input (in code this is input 0), you can chance the mode of what information the node has to run over.  Also the 4 inputs of this node are used in case you need information of other geometry.

An important thing that comes with VEX is understanding what attributes are in Houdini. Everything has attributes. For Example if you make a box each point has a position attribute that is called P (These have X,Y and Z information). So in a wrangle node if you type @P you can overwrite the position of the points. Look in the geometry sheet to see all the attributes that are currently on an object.


There are of course more attributes like @N (normal) and @Cd (color). You can also start making your own attributes to store information that you later can access again in a node. Example type "i@Example = 1;"  this will add an integer that is called example to the geometry sheet. The I before the @ stands for integer.


Photo shows custom attribute example with ints.


Starting with VEX

For starting with VEX I recently followed a 20 day program with small exercise every day. It is called Joy of VEX (totally not inspired by Joy of Painting).

You can follow these exercise too, It starts quiet basic with deforming geometry and coloring it.

http://www.tokeru.com/cgwiki/index.php?title=JoyOfVex

Here are some examples that where made by following the website. Overall it was quiet interesting to follow all these exercise and later will be more clear if this was a good beginning and where these where useful. This is also the first post and is more a intro to VEX and making some examples to see what we can do with it.


A cone that is moving around in circles.

To let an object move in a circle you will need the cos and sin. In the X and Z pos you will fill in these:

@P = set( sin(@Time+@ptnum*freq), 0, cos(@Time+@ptnum*freq));

 Notice also that Y is the up axis in Houdini and here it is value 0. By using the @Time we can animate this and by the animation timeline at the bottom of Houdini, when you press play it will move. Further by adding the @ptnum (current point number) will make sure that if there are multiple points there are not set to the same position. Then multiplying by freq which is here a custom variable with a slider. You can create a slider (aka making a parameter) by putting  ch(“name”) . Other parameters chi will give you a integer, chv will be vector, chramp will be a ramp and so on.



A cone that is moving around and looks at a point.

By taking a similar system of above can are already close. Making a point looking at another point is easily done by using the lookat function in Houdini. Also here are 2 inputs used of the wrangle, one is the rotating point and the second input is the point to look at. In VEX you can write 

matrix m = lookat(@P, p2); 

and this will return a matrix with the necessary information. P2 here stands of course for the second input. Here is an example to get information of the second input. vector p2 = point(1,"P",@ptnum); at the beginning, the first 1 stands for the second input, which means if you will in 0 it will look the first input of the wrangle.



Cable tool

This was not on the website. On the side I made some small experiments like the cable tool. 

You can get the result by creating a parabola of the line. First of course you will need a line/curve with enough points (resample node). To create the parabola this was the code

float a = ((float(@ptnum)/(@numpt)) *2 -1 );
a *= a;
a = 1-a;

To create the overlapping effect with the box or any object you want, you can use the ray node. First input will be your cable, second input is the object to overlap with.
Hanging cables with VOP also found this very useful.


Thanks so much for taking a look and a read at the blog!
That was it for this week, this week more about getting a basic understanding of VEX. Hopefully see you next time.


If you have any thoughts or feedback feel free to share it. Also if you have a cool idea of what could make this blog better let me know.