LIBRARY: Tutorials Reviews Interviews Editorials Features Business Authors RSS Feed

Creating A Sunrise Using Expressions

Creating A Sunrise Using Expressions
A CreativeCOW.net Adobe After Effects Tutorial


At Sunrise

Mylenium
Mylenium
http://www.mylenium.de
Germany

©Creativecow.net. All rights are reserved.
Article Focus:
The goal of this mini-tutorial is to show you some basic targeting using expressions as well as a few other tricks. Not only can this be used to create a stylized sun but also for lasers firing or wormholes.


Download the project files here.


Preface

The final result of this tutorial could also be achieved using manual techniques with 3D layers and a look_at expression. "So, what's the point then ?" you may say. Apart from my technique being largely automated once it is set up, there are several other things to consider:

a) 3D layers are slower than 2D layers, both while editing and when rendering.

b) Artifacts. Even though After Effects keeps getting better in 3D, it still is a rather weak tool for that kind of compositing. Even the advanced 3D renderer is far from being really advanced (nowadays it more like deserves the title "average" or "mediocre"). It's slow, has serious motion blur and anti-aliasing problems, causes quite often crashes (because it runs out of memory) etc..

c) There is a mathematical problem - at one point our layers are likely to show unwanted flipping if they were 3D. There are ways to avoid and compensate for it, but we will spare ourselves the trouble this time around.

That's why I try to avoid 3D in After Effects whenever possible and settle for 2D solutions instead.



Step 1: Setting up the project

Unlike in some of my other tutorials this is really simple this time. If you like, you can even do everything in one comp but I prefer to have two compositions - the main one called Sun and one separate comp for the Beam element. Apart from that, we only need to add two layers (or Null objects) to the main composition which will control everything. I named them Center and Target and Controller. Imaginative, isn't it? You can modify Center in any way you like and use it as the disc of the sun. The other layer will remain hidden and is really only used for animation and setting parameters. To keep things simple I only added a slider expression control and called it Radius.


Step 2: Beam me up Scotty

The look of the Beam is really very much a matter of your personal taste. The only immediate requirement is to make the composition 1000 pixels wide. This will simplify calculations later on. You may use other values, but I suggest to always use multiples of 100 (the reason why is explained in the Grid tutorial). Keep in mind that the more beams you use, the finer they should be. Now drop it into the main composition and set its anchor point to the leftmost edge.


Step 3: Expression time

The Beam layer uses expressions on all three standard transformation properties. First let's take a look at the position property.
center_X=thisComp.layer("Center").position[0];
center_Y=thisComp.layer("Center").position[1];
radius=thisComp.layer("Target and Controller").effect("Radius"("Slider");
my_angle=Math.PI*2/(thisComp.numLayers-2)*(index-2)-degreesToRadians(thisComp.layer("Center").rotation);
position_X=center_X+Math.sin(my_angle)*radius;
position_Y=center_Y+Math.cos(my_angle)*radius;
[position_X,position_Y]
What are we doing here? The position of a point on a circle can be expressed as functions of sines and cosines. Unfortunately the result of those is always somewhere between -1 and 1. Therefore we must multiply the results with the Radius from our Target and Controller layer and add the values to the position values of Center. Otherwise our sun would always stay in the top left corner where After Effects' coordinate system has its origin. Furthermore we are also taking precautions and already factor in a possible rotation of Center which we need to convert from degrees to radians. The circle itself is defined as a function of Pi. To split it into equal segments, we need to divide it by the number of layers in our comp (minus the two control layers).

The rotation is calculated very much as a standard targeting function:

diffX=position[0]-thisComp.layer("Target and Controller").position[0];
diffY=position[1]-thisComp.layer("Target and Controller").position[1];
myRot=radiansToDegrees(Math.atan2(diffY,diffX))-180; [myRot]
The last expression is also the simplest one. The scale is calculated as follows:
[length(position-thisComp.layer("Target and Controller").position)/10,100]
And that's it! Now go ahead and clone the Beam layer a few times and see the sun shine into your life ;o).





Feel free to ask questions regarding this tutorial in the After Effects forum at Creativecow.net


Please visit our forums at Creativecow.net if you found this page from a direct link.



Related Articles / Tutorials:
Adobe After Effects
After Effects Advanced Content-Aware Fill With Photoshop

After Effects Advanced Content-Aware Fill With Photoshop

In part three of his series on Adobe After Effects Content Aware Fill, filmmaker and After Effects artist Cody Pyper takes his deepest dive yet! Following requests from viewers in the series so far, Cody takes a closer look at how Adobe Photoshop can help you remove unwanted objects from your video footage in After Effects.


Cody Pyper
Adobe After Effects
Best Results with After Effects Content-Aware Fill: Reference Frames

Best Results with After Effects Content-Aware Fill: Reference Frames

Join filmmaker and After Effects artist Cody Pyper for a deep dive into how to get the absolute best results using the Content-Aware Fill tool in After Effects. Locked-down shots with simple backgrounds are one thing, but Cody shows the details of how to get fantastic results with complicated backgrounds and a moving camera using reference frames.


Cody Pyper
Adobe After Effects
Adobe After Effects Reverse Stabilization

Adobe After Effects Reverse Stabilization

You're going to be blown away by how you can power up your After Effects workflow with reverse stabilizing your footage! By separating your tracking from your compositing, you can focus on each step, and in addition, overcome the render order complexities when match moving elements and effects on a moving shot.


Roei Tzoref
Adobe After Effects
After Effects Content Aware Fill: When It Doesn't  Work

After Effects Content Aware Fill: When It Doesn't Work

There’s a new artificial intelligence-powered feature in Adobe After Effects called Content-Aware Fill that allows you to remove anything from your shots fairly easily! It's powerful, but if you’ve tried it you know that it doesn’t always work perfectly. So what do you do when it doesn’t work as well as you'd hoped? Filmmaker Cody Pyper is here to show what to try next!


Cody Pyper
Adobe After Effects
VFX in Adobe After Effects: An Artists Panel (NAB)

VFX in Adobe After Effects: An Artists Panel (NAB)

Join panelists Andrew Kramer of Video Copilot, Jayse Hansen, and Mary Poplin of Boris FX, along with moderator, Victoria Nece of Adobe, as they discuss the world of visual effects from an artist’s perspective.


Adobe Creative Cloud
Adobe After Effects
Scars, Tattoos & Digital Makeup: After Effects & Mocha Pro

Scars, Tattoos & Digital Makeup: After Effects & Mocha Pro

How do you add SCARS, TATTOOS or DIGITAL MAKEUP to a person's face? Learn how to use Mocha Pro's planar tracker and the Mesh Warp tool to insert a flat image/video on a (non flat) human face! Join VFX guru Tobias G from Surfaced Studio for a closer look!


Tobias G
Adobe After Effects
Compositing Secrets Everyone Can Use, Pt 5: Brightness

Compositing Secrets Everyone Can Use, Pt 5: Brightness

The first challenge to understanding the nature of brightness in compositing starts with remembering that we're not actually seeing color at all, but rather something of an illusion that appears to us as color! Join longtime VFX artist, editor, software developer, and business owner Simon Ubsdell for Part 5 of the best look behind the technology of compositing that you've ever seen, as he takes a look at the math behind brightness, and how to apply that to the compositing toolsets in your favorite editing, compositing, and color grading applications.

Tutorial
Simon Ubsdell
Adobe After Effects
60 Second Tutorial: Alien Invasion in Adobe After Effects

60 Second Tutorial: Alien Invasion in Adobe After Effects

Here's a fast, fun one! Sixty seconds to create and animate an alien using the 3D and Track Camera tools to animate your character in Adobe After Effects. Use the included files, or bring your own!

Tutorial
Adobe Creative Cloud
Adobe After Effects
What Are Adobe Motion Graphics Templates?

What Are Adobe Motion Graphics Templates?

A Motion Graphics Template, referred to as a MOGRT, is an animated sequence that is self-contained and can be used in Adobe Premiere Pro, Adobe Premiere Rush and Adobe After Effects, combining graphics, text, audio and video files, as well as vector or still images (including logos), to create a still or animation that can then be customized by the MOGRT user. The result is a dynamic creative tool that provides design freedom and is consistent to its users across apps and devices. Reuse, share, and even sell them!


Rod Harlan
Adobe After Effects
Compositing Secrets Everyone Can Use Pt. 4 - Advanced Alphas

Compositing Secrets Everyone Can Use Pt. 4 - Advanced Alphas

When most people hear the words "alpha channels", they think "transparency", but that's not exactly accurate. The truth is more complex, and a quite bit more interesting! Join longtime VFX artist, editor, software developer, and business owner Simon Ubsdell for Part 4 of the best look behind the technology of compositing that you've ever seen, packed with practical advice for applying the secrets of alpha channels that's simply not possible before understanding these underlying principles. No matter which applications you're using for editing, compositing, or visual effects, this one is a must-see!

Tutorial
Simon Ubsdell
MORE
© 2020 CreativeCOW.net All Rights Reserved
[TOP]