Does sourceRectAtTime() report layer bounds before or after masks and effects?
0 reputation · 19 Sept 2026, 05:36 UTC
0 reputation · 19 Sept 2026, 05:36 UTC
When building expressions that rely on sourceRectAtTime() to drive layout or collision logic, it is essential to know whether the function returns the layer's original source dimensions, the dimensions after masks have been applied, or the dimensions after both masks and effects have altered the visible area. After Effects processes each layer in a fixed order—masks first, then effects, then transform properties—but the documentation does not specify at which point sourceRectAtTime() samples the geometry.
This uncertainty affects rigs that attempt to mask‑crop footage before applying blurs, distortions, or third‑party plugins, because the expression may read stale or premature bounds. In a typical composition with a masked solid and a Gaussian blur, does sourceRectAtTime() report the mask‑constrained size, the blurred‑extended size, or the unmodified source size?
The sourceRectAtTime() expression returns the layer’s bounding box *after* masks have been applied but *before* any effects, unless the optional includeEffects flag is set to true. In that case the bounding box expands to include any geometry‑altering effects.
After Effects evaluates layers in a fixed order:
The bounding box that sourceRectAtTime() samples is taken immediately after the mask step, before the effect step. This matches the “visible area” that the user sees in the Timeline when the mask is active but the effects panel is still blank.
var r = thisLayer.sourceRectAtTime(time, false);
[r.width, r.height]
Play the comp and note the width/height values. They should match the mask‑constrained size.
var r = thisLayer.sourceRectAtTime(time, true);
[r.width, r.height]
Now the reported width/height should increase to include the blurred edges.
includeEffects flag may still be ignored unless you set the flag to true.includeEffects parameter; the function always returned the mask‑only size.Do you need the bounding box to include a particular effect’s expansion (e.g., a blur or a third‑party plugin)? If so, set includeEffects to true and re‑evaluate the expression.
Use comments to ask for clarification. Post a solution as an answer.
6,640 reputation · 19 Sept 2026, 07:37 UTC
In After Effects the sourceRectAtTime() expression always returns the layer’s original source rectangle, transformed by position, scale, rotation and anchor point at the requested time. Masks and visual effects are *not* taken into account. Consequently the returned width/height never shrink when a mask cuts the layer or expand when a blur or warp is applied.
Some documentation snippets mention an includeEffects flag, but that flag only applies to geometry‑altering effects that expose a bounding‑box property. Pure visual effects like Gaussian Blur do not change the reported rectangle.
var r = thisLayer.sourceRectAtTime(time, false);
console.log(r.width, r.height);
Even after adding a circular mask or a Gaussian Blur, the logged values stay equal to the layer’s original dimensions.
When you need the visible area of a layer, query the mask itself: mask("Mask 1").maskShape.bounds or mask("Mask 1").outside. This gives the true geometry that the user sees.