DEV Community

Kwesikwaa Hayford
Kwesikwaa Hayford

Posted on

Houdini: Varying carve node values for multiple splines

While Houdini allows splines/lines to grow through the carve node to, it gets tricky when a bunch of splines need to be grown over time at varying speed.
playblast

This code may help you if you are in such position.

fit01(rand(detail("../meta","iteration",0))*ch("slider")*2,ch("slider"),1)

Let's get right into it!

  • Drop a grid, size x= 2, y =10

  • Adjust rows or columns based on what you want, in this case i want to extract the columns so i push it to 50.
    Mind you I am only using a grid for demo, what you decide to use is up to you.

  • Drop a polypatch node for the extraction. choose columns in its connectivity property and tick "Output polygons".

patch node

  • Drop a "foreach primitive" node. In the "foreach_begin" node click on "Create Meta Import Node". when the new meta node appears, rename it to something short(optional but since it will be needed in the code, making it shorter is better. i made it "meta" in this case)

network

  • Now drop the carve node and pipe it between the "foreach_begin" node and the "foreach_end"

  • This is where the magic begins. in the carve properties, click on the parameter edit menu icon and choose edit parameter interface

settings

  • Drag a float parameter and add it to the existing parameters list, in my case it, I placed it under the "Second V" parameter. Now rename the "name" and "label" properties; i name both slider. and then tick the range option and change its values from 0-10 to 0 -1. click apply and accept.

parameter edit panel

  • Back in the carve parameter panel, depending on what you want to slide over, be it "First U" or "Second U", paste the code into it.

done

fit01(rand(detail("../meta","iteration",0))*ch("slider")*2,ch("slider"),1)

  • Now slide your "slider" float parameter you added and there you have it. Animate the slider.

The code in detail

  • Important part: detail("../meta","iteration",0) : as you can see the "meta" node is referenced here. what the detail does is, it gets the value of each polygon or iteration, the default being 0

  • The ch("slider") is the custom slider which multiplies with the detail value.
    detail("../meta","iteration",0))*ch("slider")
    Note that these alone will work, but in an undesirable ramp across the splines and that is where the rand function comes in
    rand(detail("../meta","iteration",0)) * ch("slider"). this uses the detail iteration value as a seed to create random values between 0 to 1. This will make the effect work nicely with the desired randomisation.
    The only thing is, some will get to the destination point and others wont. To counter this the fit01 function is used, takes the randomised value, and uses the slider as min and 1 as max.
    fit01(rand(detail("../meta","iteration",0))*ch("slider"),ch("slider"),1)
    This works perfectly, speed is varied and they all get to the end point when the slider gets to 1.

This should be enough but in order to have some sort of speed control I added a multiplier of 2 to the slider value
fit01(rand(detail("../meta","iteration",0))*ch("slider")*2,ch("slider"),1) Totally optional.

So there you have it. have fun.

Top comments (0)