Houdini - Using a solver to persist attribute transfer
Here we have a bunch of curves that change color over time and transfers their @Cd
to the grid when they come into contact with it.
When a frame cooks, Houdini evaluates the contact only on that frame, it has no “memory” as to whether they’ve touched before.
So how do we persist the color?
We do the attribute transfer
inside a solver
node, which will allow us to “accumulate” the paint just as we did with boxes.
Inside the solver node, we transfer @Cd
from input_2
onto the grid that came before – which has already been “painted”, and the painted grid is then passed to the next iteration to be painted again.
We ignore input_1
because it serves only as the “initial setup” – its input is the constant unpainted grid since nothing happens to it outside.
In pseudo-code:
def reduce(painted_grid, next_paint_stroke):
painted_grid.add(next_paint_stroke)
return painted_grid
# On the first call, we have to pass the
# reduce function an empty canvas, which
# is what input_1 is
reduce([], first_paint_stroke)
The result: