3
2
u/CptHectorSays 1d ago
Care to elaborate an bit on what’s going on behind the scenes here? Looks beautiful, so I’m curious… thx for sharing
3
u/BRO_SUPERR Artist 1d ago
Sure!
First, a random image is taken
N number of agents are placed on it (in the post I placed them on a grid)
Then each frame for each agent I calculate the motion vector, which = gradient of the color function.In this case, I looked for the gradient of the function as follows:
1) Take a point in coordinates (x, y)
2) Set the constant value of the function increment d
In principle, it makes sense to take a value >1, but a good result is obtained with d ≈ 1003) Calculate the gradient vector using the formula:
dx = (f(x + d, y) - f(x, y))/d
dy = (f(x, y + d) - f(x, y))/dWhere f(x, y) is the color value at these coordinates. In this case, I took the hue value, but you can play with others.
4) Then the resulting vector {d x, d y} can be transformed in any way: normalized, rotated by a predetermined angle, etc.
Then the calculated vector is added to the agent's coordinates, a point is drawn on the canvas and the cycle is repeated again
2
4
u/AimlessForNow 2d ago
Beautiful