What does the flicker expression do?
The flicker expression in After Effects is used to create a blinking or flickering effect on a layer. Instead of manually animating the opacity of a layer using keyframes, you can use this expression to automate the process. This is especially useful when you want to make adjustments or create a consistent flickering effect across multiple layers while editing video content. while After Effects doesn’t have a specific "flicker expression," the concept is often achieved by using random or periodic value changes through expressions like wiggle
, random
, or custom logic.
Basic Flicker Expression
blinkRate = 10;
n = Math.sin(time * blinkRate);
if (n < 0) 0;
else 100;
This basic expression uses the Math.sin function to create a flickering effect based on the defined blink rate.
Advanced Flicker Expression
t = framesToTime(time, thisComp.frameDuration) + (thisLayer.index * 12345);
function isPrime(value) {
for(var i = 2; i < value; i++) {
if(value % i === 0) return 100;
}
return 0;
}
isPrime(t);
This advanced expression checks if the current frame is prime to determine the opacity, creating a unique flickering effect.
How to use the Flicker Expression:
- Locate the Opacity Control: In your After Effects interface, select the layer you want to apply the flicker effect to. Navigate to the "Effect Controls" panel. If you can't find it, go to the top menu and click on "Window" and ensure "Effect Controls" is checked. Within the "Effect Controls" panel, you'll find the "Opacity" control.
- Alt-Click on the Stopwatch: Next to the "Opacity" control, there's a stopwatch icon. Hold down the 'Alt' key on your keyboard and click on this stopwatch. This action will open up a text box where you can type in your expression.
- Type in the Expression: There are various ways to write a flicker expression, but a common method involves using the Math.sin equation. This equation returns a value between -1 and 1. Based on this value, you can instruct After Effects to change the opacity of the layer. For instance, if the returned value is less than zero, you can set the opacity to 0 (making the layer invisible), and if the value is greater than zero, you can set the opacity to 100 (making the layer fully visible).
- Adjust the Blink Rate: The blinkRate in the expression determines how fast the layer flickers. By adjusting this value, you can control the speed of the flickering effect.
- Preview: Once you've entered the expression, you can play back your composition to see the flickering effect in action. If it's too fast or too slow, simply adjust the blinkRate value.
It's at this juncture that your vision can truly come together. If you've set everything up correctly, you'll have all the options and avenues you'd ever want to achieve the right look. Using the flicker expression, you can dial everything in and add the exact vibe you were aiming for. The idea is to have everything set up in such a way that you can make the majority of your creative decisions at this phase. It makes it so easy to iterate, customize, and achieve the exact feeling you were going for.
Flicker Expression Examples
Here are some examples of basic and advanced ways of using the Wiggle Expression in videos that you create with either After Effects templates or presets
Basic Flicker with Wiggle
The simplest way to create a flicker is by applying the wiggle expression to the opacity of a light or layer. This causes the property to randomly fluctuate over time, simulating an unpredictable light source like a candle or neon sign.
Example: wiggle(10, 50) will create a subtle but dynamic effect.
10: Frequency (10 times per second).50: Amplitude (flicker intensity, changing up to ±50% from the base opacity).
Strobe Flicker (On/Off Look)
For a harsher, on-and-off flicker effect, you can use a conditional expression to make opacity alternate between two values, such as 0% and 100%.
Example: seedRandom(time, true); if (random(1) > 0.5) { 100;} else {0; }. This creates a chaotic on/off flicker.
Customizable Flicker with Controls
For more control, link the flicker speed or intensity to sliders using the Expression Controls. This way, you can tweak the flicker without altering the expression directly.
- Add a Slider Control (Effects > Expression Controls > Slider Control).
- Apply this expression to opacity:
- freq = effect("Frequency")("Slider"); amp = effect("Amplitude")("Slider"); wiggle(freq, amp);
- Adjust the sliders to control the speed (frequency) and intensity (amplitude) of the flicker.
Advanced Flicker for Lights
To simulate realistic light flickers (like a faulty fluorescent bulb), you can combine periodic random values with easing:
Example: freq = 5; amp = 80; timeFactor = Math.sin(time * freq) * amp; value + timeFactor;
This creates a flicker effect with a slightly smoother, more natural feel.
Where to Use Flicker Effects
Here are some scenarios of videos where a Flicker effect will make sense and give the desired 'wow' factor for you content.
1. Horror and Thriller Scenes
- Use flicker on light layers to mimic faulty or blinking lights in a haunted house, broken streetlights, or eerie industrial environments.
- Apply it to shadow effects to create unsettling, unnatural movements.
2. Fire and Candlelight Simulations
- Flicker can add realism to flames or candlelight by applying subtle changes in brightness or opacity.
- Combine it with color shifts for a warm, dynamic glow.
3. Retro Effects
- Simulate a vintage TV screen or old film projector by adding flicker to brightness, contrast, or saturation levels.
- Pair it with grain effects and slight frame jitter for authenticity.
4. Digital Glitches
- Apply flicker to text opacity, position, or scale for a glitchy, unstable digital aesthetic.
- Combine it with displacement maps or time remapping for a full glitch effect.
5. Music and Audio Visualizers
- Link a flicker expression to an audio layer’s amplitude to sync the effect with beats or basslines.
- Use this technique for concert promos, music videos, or party visuals.
6. Neon Lights and Signage
- Add a flicker to neon text or shapes to mimic malfunctioning lights or a pulsing glow.
- Works great for retro, cyberpunk, or urban settings.
7. Explosion Aftermath
- Mimic electrical surges or sparks after an explosion by applying flicker to nearby lights or objects.
- Blend this with particle effects for added realism.
8. Sci-Fi and Futuristic Effects
- Use flicker to represent energy fluctuations in holograms, power cores, or sci-fi weapons.
- Apply it to opacity or glow effects on alien tech or spacecraft.
9. Emergency Alarms and Signals
- Flicker works well for flashing emergency lights, alarm beacons, or hazard indicators.
- Adjust the frequency for a steady pulse or chaotic warning signal.
10. Flashbacks or Dream Sequences
- Apply flicker to opacity or exposure levels to simulate disjointed, fleeting memories or surreal transitions.
- Pair with blur effects for a hazy, dreamlike feel.
11. Nightclub and Concert Lighting
- Use flicker on light layers or color effects to mimic strobe lights or dynamic stage lighting.
- Great for high-energy scenes or music-focused animations.
12. Typography Animations
- Add flicker to text layers for edgy, impactful titles or transitions.
- Works especially well with horror, sci-fi, or glitch-style typography.
13. Environmental Effects
- Simulate lightning by flickering brightness or exposure levels across a scene during storms.
- Use it for shimmering reflections on water or ice under fluctuating light sources.
14. Brand Promos and Adverts
- Flicker effects can draw attention to key elements like logos or slogans.
- Subtle flickers can emphasize modernity, creativity, or a high-energy vibe.