A bunch of points travel through a volume while avoiding obstycles drawing non-intersecting curves.
Points and volume are mutually affecting each other: The volume is cumulatively painted by the distance to the nearest point while the points are moving along the gradient of the constantly updated volume.
The volume is initialized by raytracing shadows using intersect()
and a gradient along the bounding box bb.y
. So the points will later travel upwards while escaping from shadow areas.
// volume wrangle
vector dir = chv('direction');
dir = normalize(dir);
int prim_hit = intersect(1, v@P, dir, vector(0.0), vector(0.0));
vector bb = relbbox(0, v@P);
f@d = prim_hit < 0;
f@d *= bb.y;
Inside the solver the points paint the volume by distance
leading to dark trails through the volume. That way other points will avoid crossing the trails later.
// volume wrangle
int pt_near = nearpoint(0, v@P);
vector pos_pt = point(0, 'P', pt_near);
float dist = distance(pos_pt, v@P);
float mask = smooth(0.02, 0.05, dist);
f@d *= mask;
Moving points along the volumes normalized gradient. Points travel towards bright areas of the volume, avoiding shadows, boundaries and point trails.
// point wrangle
vector grad = volumegradient(1, 'd', v@P);
v@P += normalize(grad) * 0.01;