Website powered by

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.