A while ago I was talking to an FX artist I work with who casually mentioned using inverse square law as a way to calculate falloff. I of course had no idea what he was talking about so I looked it up on wikipedia and it just so happens that the math for it is extremely simple.

https://en.wikipedia.org/wiki/Inverse-square_law

Inverse square law is used to calculate light intensity most of the time and it has a similar effect to an area light. I however found it is useful when trying to create a falloff for a number of different setups.

To setup the image above I've made my scene using the nodes to the left. Everything actually happens in the wrangle though.

So basically all you need to do is get the distance between your source and all the other points and then do 1/distance². That looks something like this in a wrangle ↓

vector P2=point(1,"P",0);

// grab the position of the point created with the add sop

float dist = distance(v@P,P2);

// calculate distance between all the scattered points and the single point created with the add sop

v@Cd=1/pow(dist,2);

// set color 1/distance². *Note that the pow() function just takes the first value and raises it to the power of the second value. This means pow(dist,3) is distance³

## Comments