Skip to content

Instantly share code, notes, and snippets.

@howiemnet
Last active January 7, 2019 04:58
Show Gist options
  • Save howiemnet/df25cb53537103fc8c4530d8b9acfb66 to your computer and use it in GitHub Desktop.
Save howiemnet/df25cb53537103fc8c4530d8b9acfb66 to your computer and use it in GitHub Desktop.
Blur objects at infinity depending on camera settings - After Effects expression
//
// This expression, applied to the blur radius of a Lens blur effect, will calc the right amount of blur
// to apply to objects at infinity (eg star fields) depending on the focus dist / aperture of the current active camera
//
// For safety it maxes out at 100 px (!)
//
try {
focLen = (thisComp.activeCamera.cameraOption.zoom * 102.05) / thisComp.width;
blurDiam = (focLen * thisComp.activeCamera.cameraOption.aperture) / (thisComp.activeCamera.cameraOption.focusDistance - focLen);
Math.min(100,Math.abs(blurDiam)/2)
} catch(err) {
value
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment