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

 

 

 

 

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

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.

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

 

I'm guessing you still need to add that.

 

Cheers,

 

Justin

 

 

andrewj58079655
Participating Frequently
August 27, 2020

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!

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