Automated Light Spills for Muzzle Flashes & Lightning Using Expressions


So I recently came across a really neat article by Mark Shingleton where he automated the exposure of a layer with the exposure of another layer. This type of automation could be a huge timesaver, especially when creating light spills from a lightning storm or muzzle flash.


Basically what this expression does is it analyzes the luminance of a layer every single frame and spits out a value that can be used by another layer (in this case, the exposure). Here’s the code as provided by Mark:

exposure = effect("Exposure")(3);
multiplier = 2;

driverLayer = thisComp.layer("MuzzleFlash");
samplePoint = [0,0];
sampleSize = [1280,720];

lightnessSample = driverLayer.sampleImage(samplePoint,sampleSize);
driverLightness = rgbToHsl(lightnessSample)[2];

exposure = driverLightness * multiplier;

As Mark stated, don’t hesitate to play around with the expression! Feel free to modify and change it up to suit your needs, if you need a strong effect, try playing with the “multiplier” value.

Many thanks to Mark for sharing his discovories and a thanks to Sam from Corridor Digital for sending me this screenshot. How would you guys use this expression? Got another tip to add that would make this expression even more useful? Let us know by dropping a comment down below.

About VinhSon Nguyen

VinhSon Nguyen is a motion graphics designer and hosts a series of creative design tutorials related to Adobe After Effects on CreativeDojo.net. Aside from motion graphics, he enjoys music, photography, and sketching.
View all posts by VinhSon Nguyen

There are 4 comments. Add your comment.

  1. Hey VinhSon,

    Thanks for sharing this around. The original concept for this was inspired by Dan Ebberts contribution to a request at Creative Cow – have a hunt around on there sometime. He’s an expression magician!

    • VinhSon Nguyen

      Ah, thanks for letting me know. Dan is a complete whizz, his sites have also helped me with expressions!

  2. BuTeKK

    thanks all of you, guys, from Russia :)

    • VinhSon Nguyen

      Thank you for your support!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>