Monday 16 February 2015

Houdini Space Colonisation Python SOP & VEX Infection Growth

First post of the year and I though I would start with something technical. I have been looking a lot into procedural modelling, growth and aggregation methods in Houdini lately and have implemented some using VEX and Python.

The first method I implemented was space colonisation using a Python SOP in Houdini. This takes a set of input points, which will be referred to as leafs, then starting from a root point we add new branch points which grow towards the leafs. Once a branch point gets close enough to a leaf point then the leaf point is removed. Finally we loop over all the branch points and attach them together.

How I implemented this with a Python SOP:
  • Loop over all the input points and using there position create an array of leafs.
  • Create a root branch and begin the growth process.
  • Start by comparing every leaf to every branch and check the distances. If the distance is to close then remove the leaf. If the distance is too far then do nothing.
  • If the distance is with in the range then check to see if this branch is the closest branch to the leaf and get the direction. Each leaf can only attract one branch at a time.
  • Now for every branch that was in range we need to get its average growth direction as branches can be attracted to multiple leafs. To do this we add the direction we got earlier to the growth direction of each branch. We also increment the branch growth count variable.
  • Now we loop over the branches and find any branch with a growth count more than 0.
  • Then we divide the growth direction by the growth count to get the average direction.
  • We create a new branch using the average direction and set its parent to the previous branch.
  • We also need to reset the parent branch growth count and direction. 
  • Repeat the the growth process until all leafs are removed.
  • Loop over all the created branches and create points as well as lines to link them all together.  
Here is a video of the final result.

For my next method I used VEX and a SOP solver to create infection like growth. Basically I started with a set of points. Then I created an integer attribute which stated wether that point was infected or not. Finally using point clouds I found the closest point the was not infected and moved the infected point towards it which then infected that point. This process is then repeated.

Here is how I implemented this:
  • Create a set of points with an infected integer attribute.
  • Set some of the points infected attribute to 1.
  • Now inside a SOP solver find the closest point using a point cloud. However if the point is infected ignore it when doing the point cloud look up.
  • Move the infected point towards the closest point found in point cloud by updating its velocity attribute.
  • Finally integrate to update the position and when the point is close enough set the infected attribute to 1. 
SOP Solver Network. Done with wrangle nodes.
Here is a video of the final result.

No comments:

Post a Comment