ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Another "get 2D point from 3D co-ordinates" question...but different

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Paul Roper
Another "get 2D point from 3D co-ordinates" question...but different
on Apr 5, 2018 at 11:24:25 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 300x300 pixels, the main_footage.mov layer is 1920x1080 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.
http://paulroper.com/


Return to posts index

Dan Ebberts
Re: Another "get 2D point from 3D co-ordinates" question...but different
on Apr 5, 2018 at 3:53:11 pm

Try changing the last line to this:

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


Dan



Return to posts index

Paul Roper
Re: Another "get 2D point from 3D co-ordinates" question...but different
on Apr 5, 2018 at 5:07:12 pm

That seems to have done it - thank you!

Dan, you are, as ever, the man!

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


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]