View all expressions
Conditional

Dynamic Drop Shadow Based on Light Source

Controls Drop Shadow direction, distance, and softness based on the position of a light source.

Contributed by:


// Apply this to the Direction property of the Drop Shadow effect
light = thisComp.layer("Light Source").position;
obj = thisLayer.position;
angle = radiansToDegrees(Math.atan2(obj[0] - light[0], light[1] - obj[1]));
angle; // Apply this to the Distance property of the Drop Shadow effect
light = thisComp.layer("Light Source").position;
obj = thisLayer.position;
maxDist = 100; // Maximum shadow length
dist = length(light, obj);
linear(dist, 0, 500, 10, maxDist);
// Apply this to the Softness property of the Drop Shadow effect
light = thisComp.layer("Light Source").position;
obj = thisLayer.position;
maxSoft = 300; // Maximum blur
dist = length(light, obj);
linear(dist, 0, 500, 5, maxSoft);

Dynamic Drop Shadow Based on Light Source

Practical use case

Useful for motion design with realistic lighting, making shadows move dynamically with light sources.

Check out similar expressions

Data-driven video workflows for After Effects are easier with Plainly.

a mesh of elegant lines transparent image