banner



How To Animate A Lens Flare In After Effects

Layer Space Transforms



Instance Study: 3D Lens Flare

Here's a applied application of a layer space transform (in that location are many). Here's the setup: Yous've constructed an elaborate 3D comp and y'all animate a lite moving through information technology. You would similar to make the light itself visible some how. You get the brilliant idea that if you could only position a lens flare on top of the lite you could accomplish the result. The problem, of grade, is that the Lens Flare Effect is a 2d result that you apply to a second layer. So what nosotros need is a way to map the position of the low-cal in 3D space to the 2D plane that represents the camera view.

This is the perfect job for the "toComp" layer space transform. We use "toComp" instead of "toWorld" in this case because we want the Lens Flare to follow the lite's position in the camera view (which is what "toComp" does), not in earth space.

Call up that when you use "toComp" you want to commencement with a point that's represented in the layer's infinite coordinates (i.e. relative to the layer's upper left hand corner). For most layers, the anchor bespeak is the logical choice for this because the ballast betoken is e'er expressed in the layer's coordinate system. To verify this, just create a layer of any size and you notice that the 10-coordinate of the anchor point is always one-half the layer's width and the y-coordinate is half the layer's height.

Unfortunately, lights and cameras don't take anchor points. That's OK, because all that nosotros really need is to know where, expressed in the lite'south coordinate system, the light is. It turns out to be [0,0,0]. Then all we need to do is write an expression for the "Flare Center" parameter that maps it to the "toComp" transform of the light'south position. Here's the code:

                      Fifty = thisComp.layer("Light 1"); 50.toComp([0,0,0]);                  

Deceptively simple, actually.

The first line simply sets the variable "L" equal to the layer object "Light i". It'southward non really necessary to do this for a simple example like this. We could simply every bit hands take written the code in one line like this:

                      thisComp.layer("Light 1").toComp([0,0,0]);                  

But I similar to practice it this way because most of the time you lot cease upwardly needing to refer to the layer more than one time in your expression and I think it makes in more readable considering you can only substitute "L" anywhere yous would normally write "thisComp.layer("Light 1")".

The second line of the expression is where all the magic happens - the point [0,0,0] in the light's infinite is translated to the equivalent position in the camera view's space. This value is now suitable to use to position the lens flare.

OK - we've only got one other problem to solve. In our animation, the low-cal moves away from the camera. To really sell the effect, we need the lens flare to diminish equally the light moves away. Unfortunately, the Lens Flare effect doesn't take a "size" parameter. However, information technology turns out that for our purposes an expression for the "Flare Brightness" parameter that makes the brightness diminish every bit the light moves away works just fine. Here's the code for that:

                      factor = 150; C = thisComp.layer("Camera 1"); L = thisComp.layer("Calorie-free one"); d = length(C.position,50.position); d1 = length(C.position,L.position.valueAtTime(0)); d1/d*factor                  

This expression calculates the initial distance between the light and the camera (d1), divides that by the electric current distance between the low-cal and the photographic camera (d) and multiplies that by the maximum value of flare brightness that nosotros want (factor).

So there you accept it. A pretty nice effect implemented with very little code.


previous

Source: https://www.motionscript.com/mastering-expressions/lst-lens-flare.html

Posted by: salazarexions.blogspot.com

0 Response to "How To Animate A Lens Flare In After Effects"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel