Search
• Josh

# Inverse Square Falloff

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.

Inverse square law visualized with point color

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³

### Recent Posts

See All

#### VEX SNIPPETS Pt.2

Some more helpful vex that I'm trying to type less often 1: Move to set on Grid and Set Pivot to Origin in a point wrangle... vector centroid = getbbox_center(0); vector dist = centroid - 0; vector mi

#### VEX SNIPPETS Pt.1

Some helpful vex that I use on the daily 1: Center Pivot and Move to Origin in a pointwrangle.. vector centroid = getbbox_center(0); vector dist = centroid - 0; v@P -= dist; 2: Random Normal in a poin