Skip to main content
Participant
November 6, 2024
Question

How to get position of checked out layer in composition coordinate space?

  • November 6, 2024
  • 1 reply
  • 337 views

I'm implementing an effect that has a layer parameter and blends the image from that layer with the layer that the effect is applied on:

- The effect is applied on LayerA which is 1920x1080
- The effect's layer parameter is set to LayerB which is 800x600

 

Everything works except that the image coming through the layer parameter (LayerB) is always positioned at the top left corner of LayerA, regardless of where I positioned LayerB in the composition.

 

When I call checkout_layer() during PF_Cmd_SMART_PRE_RENDER, the returned result_rect rectangle has the correct dimentions (800x600) but the top and left fields are always set to zero, regardless where I positioned LayerB.

 

Interestingly, if I create a Shape layer instead of importing an image from disk, I observe that checkout_layer() returns correct values for top and left fields of result_rect and I get the result that I expect.

 

What do I need to do to get the position of a layer passed via layer parameter, when the source of that layer is an image that I imported from disk?

 

Thank you!

This topic has been closed for replies.

1 reply

James Whiffin
Legend
November 9, 2024

Hi Pedro

 

Shape layers will give the correct values because they are continuously rasterised and are in composition space, not layer space.

 

If the layer does not have collapse transforms on (AV layers), I believe you can get this information from the origins of the layer you checked out and add that to the position values. 

Participant
November 11, 2024

Hi James,

Are you referring to the values returned by PF_CHECKOUT_PARAM?

If I use PF_CHECKOUT_PARAM to access the PF_ParamDef data structure of that layer, the .u.ld.origin_x and .u.ld.origin_y are always zero for a layer that only contains an image that I imported from disk.

Please let me know if I misunderstood your hint.

It's surprising to me that AE won't provide a way to get the position of the image coming in through a layer parameter, but I'm at a loss on how to do it.

James Whiffin
Legend
November 17, 2024

Hi Pedro

It's best practice to use checkout_layer_pixels and not via PF_CHECKOUT_PARAM when using smartFX, that should allow you to get the origins. LayerA (where the effect is applied) and LayerB (selected in the layer param) should both be continuously rasterised for this to work.