Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Another “get 2D point from 3D co-ordinates” question…but different

  • Another “get 2D point from 3D co-ordinates” question…but different

    Posted by Paul Roper on April 5, 2018 at 11:24 am

    Hello,
    I’ve got a shot which I’ve tracked successfully and have a 3D camera. The shot is a slow pan across some objects. I need to remove something from one of the objects, so I’ve placed a 3D solid in the comp to cover it and it all works nicely. What I now want to do, is use a 4-Color Gradient to add a gradient to the solid that matches four of the colours of the underlying footage. I tried adding this expression to each of the four colours in the 4-Color Gradient effect:

    sourceLayer = thisComp.layer("main_footage.mov");
    p = effect("4-Color Gradient")("Point 1"); // position of the pixel you want to sample
    r = [3,3]; // radius of the sample point
    sourceLayer.sampleImage(p,r)

    (obviously changing “Point 1” to “Point 2”, etc. for each of the 4 points)

    If everything was 2D, this would work perfectly. But my Solid layer is 300×300 pixels, the main_footage.mov layer is 1920×1080 and the Solid layer is sitting in 3D space. So the 4-Color Gradient’s “Point 1” might be at 30,30 but in real life in the comp, it’s at something like 800,600. How can I get the absolute value of this point? I’ve tried adding .toComp to various bits without success.

    Any suggestions, anyone, please?

    motion graphics | VFX | web design | etc.
    https://paulroper.com/

    Paul Roper replied 8 years, 1 month ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    April 5, 2018 at 3:53 pm

    Try changing the last line to this:

    sourceLayer.sampleImage(sourceLayer.fromComp(toComp(p)),r)

    Dan

  • Paul Roper

    April 5, 2018 at 5:07 pm

    That seems to have done it – thank you!

    Dan, you are, as ever, the man!

    motion graphics | VFX | web design | etc.
    https://paulroper.com/

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy