Water paint simulation
Paint tool using water paint on top of a fluid simulation. A user paints colored pigments onto a canvas after which they may be moved by fluid effects.
Pigments float around in the wet parts of the canvas and currents are created by the users brush as well as by water evaporation.
proc DragBrush(Wq, vx, vy, dt , brush , px, py, dx, dy):
for cells(i, j) in brush−>range(px, py) do
force = sqrt((i−px)ˆ2+(j−py)ˆ2) / brush−>range; vx(i,j) += force ∗ dx;
vy(i,j) += force ∗ dy;
if(brush−>isWet()) do
addition = force ∗ brush−>Wq;
wq[idx] += addition;
brush−>Wq = max( brush−>Wq − addition , 0)
else
reduction = 1−(force ∗ 1 / 20); brush−>Wq = min ( brush−>Wq + Wq[ idx ] ∗ reduction , brush−>maxWater ) wq[ idx ] ∗= reduction
end if
end for
end proc