Skip to main content
andrewj58079655
Participating Frequently
August 26, 2020
Question

Expressions Bug - Opacity affects Scale

  • August 26, 2020
  • 5 replies
  • 1043 views

Hi,

 

There seems to be a weird bug when an expression is applied to opacity and scale.

I am developing a tool which transforms a layer based on it's position to a null - similar to an effector in C4D. I am using the same expression on each property.

When I togggle the expression on/off on opacity, it affects the scale of the layer. Weirdly the bounding box of the shape layer remains as it should. This is the same for image layers as well.

I have tried this with multiple versions of AE and uninstalled/re-installed - the problem is the same.

 

Can somebody shed some light on this very weird bug please?

This topic has been closed for replies.

5 replies

Community Expert
August 29, 2020

I downloaded the project. Running the File/Scripts/Update Legacy Expressions.jsx file fixes the Javascript errors. The Rotation expression on layer 1 (Center Null) is pointing to an unknown asset but it doesn't seem to affect any of the behaviors.

 

The Anchor Point of Layer 3 is not in the center of the graphic so when it is scaled the layer moves just a little bit down as the controller layers approach. The Position property is also tied to the position of the null so the layer moves even farther down as the null approaches. When the controller layer pair of layer 1, which only controls the position of Layer 2 (guide) approach the layer 3 anchor point the layer scales and the opacity changes. 

 

If you replace Variable D in all of the expressions with a value like 250 or even tie variable D to a slider you can eliminate the Guide shape layer. It serves no purpose at all other than a visual representation of the radius of the sphere of influence that the distance between the null and the Object layer has over the position, scale and opacity. 

 

I don't know exactly how you want the layers to behave, but there is nothing wrong with the expressions on the Object layer that can't be converted to Javascript and there is nothing unexpected in the behavior. The setup is just not very efficient. If the Object layer is scaled by the approaching null the bounding box changes size as does the layer. Turning off any of the expressions has the expected result.

 

I'm not sure what you think is going wrong with the sample comp, but I cannot find anything that is not behaving exactly as expected. In other words, the only problem that I see is the Rotation expression on the Null layer, and the only workflow cleanup that I see is the elimination of the Guide shape layer because it doesn't render. If you need a different behavior then it would be a good idea to tell us what that behavior is.

 

Martin_Ritter
Legend
August 29, 2020

I had placed to null close to the shape layer, so the moving, scaling and opacity effect comes in.

In this position, I deactivated the opacity expression and the shape layer did changed its size. Just as OP noticed.

After purging Cache, the shape layer had its expected size.

 

Can you confirm this behaviour, Rick?

 

If not, that would be interessting - you are on a Mac, right?

 

*Martin

andrewj58079655
Participating Frequently
August 27, 2020

Thanks for your replies so far.

 

Rick, I'm not sure if you meant to post that here - looks like something very different, but thanks anyway!

 

Here is a project that contains the problem - 

 

https://we.tl/t-KXclr8ypkw

 

There are two problems - 

 

First, when the opacity expression is disabled, it affects the scale of the layer, even though the bounding box remains the same.

 

Secondly, the scale expression measures the distance from the initial starting position of the layer, which is what I want, however, the opacity expression measures the transformed position, not the initial position, which is not what I want.

 

It's very strange. I've been pulling my hair out for weeks now - any ideas anybody?

 

Thanks very much

 

 

 

 

Martin_Ritter
Legend
August 27, 2020

I spend some time with the project now, and I think I got it:

 

As Justin said, switching to JS engine throws errors and I declared the functions before calling them. But this wasn't the issue, or just a part of it.

 

I got rid of all var, changed function names to individual names, got rid of the pseudoeffect in the null, hardcoded the values, changed variable names to individual names, and even get rid of the linear and the functions itself... but nothing of this helped.

 

However, I noticed that purging the cache restored the expected visual outcome without any scale jump.

Clearly you created a backloop somehow.

 

So I added sliders and 3D point controls to the shape layer and outsourced your repeating calculations from the expressions to them. I only did this for opacity and it already works.

 

When doing so, I got an error on every "var", so I got rid of them again.

 

I hope this helps, report back if not.

 

*Martin

Martin_Ritter
Legend
August 27, 2020

This is definitely working better Martin - thank you very much!

 

Getting rid of the repeating calculations will speed things up a lot, and it solves the first problem with the transforming position.

 

However, I'm still getting the bug when disabling the opacity expression. In fact, now the position stops working until I purge memory. Do you know what might be causing this problem with the memory?

 

Thanks again


Strange - position always works as intented, and opacity worked after the fix on my side.

Did you update all expressions following my example?

 

Unfortunatly the code looks good to me. And I have no idea what is causing this.

 

Of course, if you call a function only once, there is no need for one, but this should still be evaluate correctly.

I would try to get rid of every neccassary line of code, namely the functions and the var-declaration (you don't necassary need it, because expressions are evaluated on every frame and there is no "global" concept in AE), as troubleshoot. 

Also, I would write to code as dump as possible. You can get the effect value by a simple declaration and instead of calling the property by index, call it explicite. The easiest way to do so it to pigwhip the slider from the expression window (I think you know what I mean and how to do it). 

 

After all of this, the only "complex" thing left is linear(). You can use your own calculation instead and see, if this helps. After this there is just most basic math left and if this isn't working, I don't know what else will.

 

*Martin

Community Expert
August 26, 2020

EDIT: Somehow this post ended up on the wrong thread. Here's the thread if you are interested.

 

This is a lot easier than you think. A 3D layer's rotation has four properties, Orientation (X, Y, and Z) and Rotation X, Y, and Z.

 

If you create the Hexagon with a flat side on the bottom, put the anchor point on the bottom, then change the orientation to 0, 0, 30 or 0, 0, 330 the bottom will now be parallel to one of the sides of the master hexagon and you can simply drag the Z rotation value in the timeline to rotate around the proper axis. Do the math and you can line up any polygon with any other polygon, you just have to match the Z value in orientation with the edge you want to match.

 

Fortunately, it is very easy to create a hexagon on a shape layer. Once it is created you can expand the properties, set Transform/Polystar 1/Rotation to 30º, select the Anchor Point tool (y), turn on snapping, move the anchor point to the bottom center of the Hexagon and it will snap there, then you can change to the Selection tool (v) and drag the Hexagon to the edge of the second polygon and it will snap to the edge and the center. Then all you have to do is set the orientation to 0, 0, 330 to line up the bottom edge of the Hexagon with the other Hexagon. All that is left is to drag the X rotation value to rotate the shape around the bottom edge. It looks like this:

It's just math. I use math all the time to line up and arrange things in 3D space. AE's ability to snap to vector paths and layer edges makes it easy.

Justin Taylor-Hyper Brew
Community Expert
Community Expert
August 26, 2020

Sounds like you're using global variables that are affecting more than one of your parameters.  Are you using the Legacy or JavaScript engine for expressions? Can you share a sample of your expression?

Martin_Ritter
Legend
August 26, 2020

I have never experienced such a behaviour - can you give us more technical details (hardware and software versions), as well as the expression itself?

 

*Martin