Hey all there,
when it comes to do fluid simulations in Houdini it is often necessary to be able to re-time the caches after the simulation. In principle that is not a big deal – just an interpolation between two frames. It gets a little harder if we have a constant emission which leads to a changing point count. In this case we have to build a setup like this.
First we start with a Null that gets three float Parameters as a input (Current Frame, Frame A and Frame B). The Current Frame should have an Animation on it, and the two others get a nice little Python snippet:
FrameA = ch(“CurrentFrame”)
FrameB = ch(“CurrentFrame”)
Next lay down two File nodes and input the simulation.
With this done we’ll always get the Current Frame and the next frame as inputs. An example would be: Current Frame 55.8 => Would be Frame A = 55 and Frame B = 56. Since the Frame A always has the lower point count we need to make an detail attribute “nptA”, that holds the point count of Frame A. With the help of an attribute transfer we can copy the detail attribute to the Frame B stream. In the delete sop that follows the attrib transfer we throw away all the new points of Frame B, so that we can interpolate the Points of Frame A with Frame B. There for use this little expression $PT >= @nptA.
The logic happens now in the pointvop. Connect the two streams and create two parameters: A velocity mulitply and a attribute blend float. On sop level the attribute blend parameter gets this expression: ch(“../Time/CurrentFrame”) – ch(“../Time/FrameA”) the result is always a blend value between 0-1, that we can use for mixing values in the point vop. The velocity muliply parameter gets this expression: chf(“../Time/CurrentFrame”, $F + 1) – ch(“../Time/CurrentFrame”) the result is a the difference between the Current Frame (of the Time Null) and the next Value on the fcurve of this parameter. I do that to make sure that the velocity scales proportional to the retiming curve. The nodes of the pointvop are just some mixing and binding. Note: If you have other attributes that you want to interpolate just also import them for the two streams and blend them. Yeah!
When this is done we have to care about the other new points that will be born on Frame B. Because I have no information when the Particles where born between the two frames I add them randomly over the animation time with the now expression. @randomDEL > ch(“../Time/CurrentFrame”) – ch(“../Time/FrameA”) Check my post if you want to now more about how you do a “Test Random Propability in Houdini)
The rest is just merging and cleanup. A last quick node. If you use the fluid compress node in combination with a compressed bgeo file it can happen, that the point index changes from frame to frame. This leads to an improper blending.
I hope you like my solution. If you have questions or acknowledgements, please drop me a line.