• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Expressions Bug - Opacity affects Scale

New Here ,
Aug 26, 2020 Aug 26, 2020

Copy link to clipboard

Copied

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?

TOPICS
Expressions

Views

409

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Aug 26, 2020 Aug 26, 2020

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 26, 2020 Aug 26, 2020

Copy link to clipboard

Copied

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 26, 2020 Aug 26, 2020

Copy link to clipboard

Copied

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:

Screenshot_2020-08-26 14.00.58_uqeK3T.png

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 27, 2020 Aug 27, 2020

Copy link to clipboard

Copied

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

 

 

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 27, 2020 Aug 27, 2020

Copy link to clipboard

Copied

Andrew,

 

So on Legacy Expression mode it works fine, but with the Javascript Expression engine it errors out on the opacity expression. Make sure you're declaring variables before using them, (I moved your function effectPush() before you use it)

 

// Object Position
var O = thisLayer;
var oP = O.toWorld(O.anchorPoint);
// Centre Null
var A = thisComp.layer("Centre Null");
var aP = A.toWorld(A.anchorPoint);
// Distance from Centre Null to Object
var L = length(aP, oP);
// Circle Size
var D = thisComp.layer("Guide").content("Ellipse Path 1").size[0] / 2;
// Hold Percentage
var H = D / 2;
function effectPush(originalValue, reactValue) {
    var outputValue = originalValue + reactValue;
    var finalValue = linear(L, D, H, outputValue, originalValue);
    return finalValue;
}
result = effectPush(value, thisComp.layer("Centre Null").effect("Effect")(3));

Do the same thing with your scale expression:

// Object Position
var O = thisLayer;
var oP = O.toWorld(O.anchorPoint);
// Centre Null
var A = thisComp.layer("Centre Null");
var aP = A.toWorld(A.anchorPoint);
// Distance from Centre Null to Object
var L = length(aP, oP);
// Circle Size
var D = thisComp.layer("Guide").content("Ellipse Path 1").size[0] / 2;
// Hold Percentage
var H = D / 2;
function effectPush(originalValue, reactValue) {
    var outputValue = originalValue + reactValue;
    var finalValue = linear(L, D, H, outputValue, originalValue);
    return finalValue;
}
result = effectPush(
    value[0],
    thisComp.layer("Centre Null").effect("Effect")(2)
);
[result, result, result];

Now opacity and scale seem to work as they should and toggling on and off the expressions works as they should.

justintaylor_0-1598541414230.pngjustintaylor_1-1598541426207.png

only issue I cant solve is a missing effect ("React")

justintaylor_2-1598541542356.png

 

I'm guessing you still need to add that.

 

Cheers,

 

Justin

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 27, 2020 Aug 27, 2020

Copy link to clipboard

Copied

Thanks for taking a look Justin, but I've copied and pasted and it hasn't worked, I still get the weird scale/opacity error.

 

Also, it looks like you've disabled the 3D switch which has thrown the position expression out, meaning we can't see the first problem (opacity expression reading transformed position rather than initial position).

 

I can't see what the difference is between my expression and yours apart from moving the function. It looks like I had declared all my variables.

 

Thanks Justin!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Aug 27, 2020 Aug 27, 2020

Copy link to clipboard

Copied

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.

 

Anmerkung 2020-08-27 182730.jpg

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 27, 2020 Aug 27, 2020

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Aug 27, 2020 Aug 27, 2020

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 28, 2020 Aug 28, 2020

Copy link to clipboard

Copied

Thanks for this Martin.

 

I'm still getting problems though. As soon as I change a value (the scale or opacity, for example), it doesn't work until I purge the memory again. Very annoying!

 

You mentioned a backloop in the code - do you know of anything that may cause this? 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Aug 28, 2020 Aug 28, 2020

Copy link to clipboard

Copied

I have no idea what's causing this, sorry.

Backloop might not even be the correct word... somehow your code messes with AE - but I can't see how.

You can only troubleshoot by eleminating every line, every function and variable, every duplication of names and calculations. 

 

See, at a certain time, all expressions evaluate to there naked values, just numbers.

If you type in those numbers, everything will work.

On the way from this total simplification to your advanced code, things are getting wrong.

And to find the cause, you have to go down the simplification road - not for the final code, but for troubeshoot or to find the bug.

 

I can't see any suspicious in your code, so that's what I would do. 

Even if this is a bug in AE, I can't see what is causing this.

 

But we all see that there is an issue, so something have to causing it. 

 

I would get rid of the functions next and write my own linear if this didn't solved anything. 

You can replace the linear with something different, like an if-condition which works with all the variables the linear does. That's not the same effect, of course, but technical troubeshooting.

Write your own linear (or something close) as a function and call it instead - any changes?

 

If this isn't getting you somewhere, what else could cause this? What if you put the expressions on 3 layers (one scale, one position, one opacity), what if one of those expressions is completly different (and all are on one layer), what if you use the expressions on the transform effect (see effect panel) instead?

What if you apply the expressions on a solid or footage layer?

 

Also, have a look at DuIK. It's a free animation toolbox. There is an effector similar as you want to create. Apply it, have a look at the expression. Maybe there is another approach.

 

Those are some questions to ask and options to try, if you really want to troubeshoot. But this also requires some time ...

 

Keep me updated on this. 

 

*Martin

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 03, 2020 Sep 03, 2020

Copy link to clipboard

Copied

LATEST

Amazing - thanks so much for your detailed reply Martin.

 

Looks like I've got some investigating to do!

 

I'll let you know what the problem was if/when I find it - thanks again!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 27, 2020 Aug 27, 2020

Copy link to clipboard

Copied

andrewj58079655

I'm not sure how that post got on this thread. If you are interested, here is the thread it was supposed to be on.

 Re: Struggling to sort this angle (in 3D space?)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 28, 2020 Aug 28, 2020

Copy link to clipboard

Copied

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.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Aug 29, 2020 Aug 29, 2020

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines