After Effects - Dynamic Shadows

Full Tutorial:

Code for Slant value:

function getWorldPos(theLayerName){
  var L = thisComp.layer(theLayerName);
  return L.toWorld(L.anchorPoint);
}

var lightPos = thisComp.layer("LIGHT").transform.position;
var myWorldPos = getWorldPos(name);
var xDistance = myWorldPos[0] - lightPos[0];

linear(xDistance, -thisComp.width, thisComp.width, 200, -200);

Code for Height value:

function getWorldPos(theLayerName){
  var L = thisComp.layer(theLayerName);
  return L.toWorld(L.anchorPoint);
}

var lightPos = thisComp.layer("LIGHT").transform.position;
var myWorldPos = getWorldPos(name);
var yDistance = myWorldPos[1] - lightPos[1];

linear(yDistance, 0, thisComp.height, 100, 0);

Code for Floor value:

toWorld(anchorPoint);

Last updated