7 Replies Latest reply on Feb 23, 2010 6:22 PM by DC B. 09

    Order of expression execution between layers

    DC B. 09 Level 1

      Hello:

       

       

      Say, I have the following order of layers (as they physically appear in the AE timeline):

       

      Camera

      Layer1

        Effect1.1

        Effect1.2

        Effect1.3

      Layer2

        Effect2.1

        Effect2.2

        Effect2.3

      Layer3

        Effect3.1

        Effect3.2

        Effect3.3

       

      Say, if every layer and effect had expressions, what would be the order of their execution?

       

       

      PS. I need to know this because I'm using toWorld/fromWorld methods, along with moving and rotating some layers, and I'm suspecting that the order of execution messes me up.

        • 1. Re: Order of expression execution between layers
          Todd_Kopriva Level 8

          This page describes the render order, but the gist is that layers are rendered from bottom to top (referring to their order in the Timeline panel). Effects within layers are rendered from top to bottom.

          • 2. Re: Order of expression execution between layers
            Mylenium Most Valuable Participant

            Say, if every layer and effect had expressions, what would be the order of their execution?

             

            All at once. Unless there is a specific order dictated inside the expression by ordering and chaining variables, the actual order of elements is not really relevant to an expression. It's in its nature of being sandboxed and not caring for the world outside until you tell it to. Whatever issues you have are in the code.

             

            Mylenium

            • 3. Re: Order of expression execution between layers
              DC B. 09 Level 1

              Mylenium, it does. It's difficult to explain, so let me attach a test project. What I was trying to achieve there are two parallel layers (planes) in 3D space and another layer connecting them:

               

              Project:

              http://www.mediafire.com/?wnllzztnmf4

               

              Diagram (top view):

              http://i150.photobucket.com/albums/s99/dc2000_bucket/scrshot_3d_lines.jpg

               

              The idea is that once the [front] or [back] layer is moved the [connect] layer should follow. I implement this by tying the Position, and Y Rotation of the [connect] layer with expressions to the other two layers. Each of three layers also has the Beam effect applied, and the Starting Point of the beam in the[connect] layer is also tied in with expressions to the [front] and [back] layers. Take a look at the project for exact expressions -- they are all in the [connect] layer.

               

              While in AE, select the [front] layer, switch to the Selection Tool and start moving that layer around. The connecting layer should follow. Now click on the [back] layer and again with the Selection Tool try to move it around. For some weird reason the connecting layer gets all screwed up. But, while it is messed up switch back to the [back] layer and move it. The connecting layer will fix itself up.

               

              So, how can you explain this behavior?

              • 4. Re: Order of expression execution between layers
                Mylenium Most Valuable Participant

                Well, then you asked the wrong question. Naturally of course effects inherit the transform properties of the parent layer, but the expression itself will evaluate per frame, regardless where it is. In your example it really boils down to you combining two unrelated transform spaces in the first place - since you make no provision in the code to enforce evaluation of the layer position, there is no way it possibly would. It only kicks in when you evaluate the effect because this causes the upstream graph also to evaluate...

                 

                Mylenium

                • 5. Re: Order of expression execution between layers
                  DC B. 09 Level 1

                  OK, Mylenium. I appreciate your analysis. But how do I fix it?

                  • 6. Re: Order of expression execution between layers
                    Rick Gerard Adobe Community Professional & MVP

                    Can't look at your project right now but if you have layer 1 linked to layer 2 by an expression and you move layer 2 layer 1 won't follow. If you write an expression with layer 1 tied to layer 2 and layer 2 tied to layer 1 then you get a circular reference and neither will work as expected.

                     

                    for example:

                    value + thisComp.layer("Layer 1").position
                    
                    

                     

                    applied to Layer 2's Position property will make layer 2 follow layer 1 around.

                     

                    But if you apply:

                     

                    value + thisComp.layer("Layer 2").position
                    
                    

                     

                     

                    to Layer 1's Position property things start to get weird because of the circular reference.

                     

                    Your observation that moving the back layer around gets fouled up until you move the front layer makes perfect sense to me because the back layer is driven by layer 1 but you can't, or at least I can't figure out a way, that you could have the front layer drive the back layer and the back layer drive the front layer without a circular reference that would foul the whole thing up.

                     

                    The only solution that I can see would be to drive both layers with a Null and animate that.

                    • 7. Re: Order of expression execution between layers
                      DC B. 09 Level 1

                      Thanks, Rick. I'll try to use Null objects for that.