Compute Flocking

Based closely on Tim Gerritsen’s hugely legible and helpful compute particles implementation.

Has a funky issue with the seeking behavior ‘flattening’ velocities to the ortho axes … I assume it’s a math error in there somewhere.

Very not optimized. Please send help.

Thanks Tim,

N

Edit: added repulsion from external targets

Edit 2: TODO: use compute optimizations like an adult

Edit 3: Seek Target radius fix

Edit 4: Fix posted based on Tim’s input – needed a resample on the texture buffer input as the start/end of the input CHOP were not being recognized by the .numSamples reference in the Uniforms, yielding a much larger (and wrong) num samples

Edit 5: Now takes FPS into account in all relevant forces and integration

Edit 6: Bug fix (thanks JetXS!)
ComputeFlock.tox (82.4 KB)

2 Likes

Really interesting - not sure what’s up here but if you try to run this with the settings as they’re saved in the .tox, in 099 Stable (latest build) the ‘obstacle’ (blue sphere) influence as its’ set (Repulse magnitude 2, Repulse Radius 4)

The exact same .toe in 099 Experimental (22270) will blow boids hundreds of worldspace units away. To get the same behavior you’d need to set them to something like .112 and .9, respectively.

Check out these images - exact same settings.

Stable:

Experimental:

I think it’s because of the ‘uObstaclesXYZRad’ input. This is a null1 chop that moves the index of the chop every frame (due to the timesliced noise you’re suppling). It seems like shader world doesn’t handle this properly.

What seems to work is adding a trim chop and trim to the absolute values 0 to 9. This will make sure the index will always stay at 0 and the numSamples always 10.
(experimental showed me some fluctuation between 9 / 10 frames, stable stayed at 9)

Hope this helps.

cheers,
tim