Activity › Forums › Adobe After Effects Expressions › Converting 3D position to 2D ?
-
Converting 3D position to 2D ?
Posted by Gil Rokplo on September 13, 2007 at 11:00 amHi !
A little trick i’m trying tio solve for a while …
I’d like to apply nice lens flares (knoll) to 3d moving lights or layers. The knoll lens flare source is a 2D position.
Do you know a way to convert a 3D position into the view/camera 2D position ?
(maybe there is a very simple expression instruction to do it, and i’m a dumb …)
Dan Ebberts replied 11 years, 6 months ago 6 Members · 11 Replies -
11 Replies
-
Dan Ebberts
September 13, 2007 at 12:09 pmLike this:
L = thisComp.layer(“Light 1”);
L.toComp([0,0,0]);Dan
-
Lord Scales
September 13, 2007 at 4:48 pmYou can also apply a fade out effect in the Scale property, to simulate the light diminishing according to the distance from the camera. The property will still be “keyframeable”.
camPos = thisComp.activeCamera.position;
lightSource = thisComp.layer(“Light Source Null“).position;
dist = length (camPos, lightSource)/650;value/dist
Change the bold text as needed.
-
Gil Rokplo
September 13, 2007 at 6:58 pmgreat ! it absolutely works !
but i don’t understand how ….
the menu in AE shows toComp(point,t=time) … and here you give me toComp([0,0,0]) ?
Do you mean we convert the [0,0,0] local coordinates of the layer to the 2D coordinates of the comp ? (using active camera and current time). This mean that, if it’s nor a light but a layer, i use the upper left corner ?
Thank you very much for some explanations ….
-
Dan Ebberts
September 13, 2007 at 8:00 pmYou would normally use anchorPoint (which is always expressed in layer space), but cameras and lights don’t have anchorPoints so you just use [0,0,0]. You’re correct that if you use [0,0,0] with a regular layer, you’ll get the upper left corner.
Dan
-
Yono Yo
May 10, 2010 at 12:53 pmHi,
I’ve got quite the same problem :
I created a cube from 6 2D layers textured and bump mapped with the CC Glass effect (anchor point at the center of the cube).Inside of that cube, I created a point light that wiggles.
I want the property “light position” from the CC Glass effect to vary according to the light in the 3D space.note : the light layer stands in a HD comp (no square pixels, 1440×1080) and the comp containing each face of the cube stand in a square pixels comp (1080×1080).
Hope I’ve been clear enough, and sorry for my english !
-
Dan Ebberts
May 10, 2010 at 4:44 pmTry this:
L = thisComp.layer(“Light 1”);
fromWorld(L.toWorld([0,0,0]))Dan
-
Andy Engelkemier
November 16, 2011 at 6:44 pmOK, this works, but I totally don’t get it. I asked this question elsewhere, but it works for me as well. I just can’t figure out why it works.
Care to explain the basics? I hate just doing something because it works without having a clue what it’s doing.
-
Dan Ebberts
November 17, 2011 at 1:28 amEven the basics are a little complicated.
There are a set of layer space transforms that you can use to transfer to and from AE’s three coordinates spaces. Each layer has its own layer space, there is the comp’s world space, and then there is comp space, which is the 2D camera view area. The example you cited:
L = thisComp.layer(“Light 1”);
fromWorld(L.toWorld([0,0,0]))is converting the light’s position in it’s own layer space to world space and then bringing that from world space into the layer with the expression’s own layer space. You would usually do this to position an effect point on the layer, which would generally use layer space coordinates.
The reason to move the light’s position into world space in the first place is in case it has a parent. When you make a layer a child of another layer, its position value is changed to be relative to its parent’s upper left corner. Using L.toWorld([0,0,0]) gives you the light’s position in world space whether it has a parent or not.
It takes a while to understand it completely. Once you get it, you can start on the vector transforms–they’re even more fun. 🙂
Dan
-
Andy Engelkemier
November 17, 2011 at 11:59 amThanks Dan, very friendly explanation. I’m starting to get why a few of my older projects were confusing me also. I always had troubles doing things like having layerA parented to layerB and then later referencing position of layerA via some expression.
The Terrible part is I was always in a hurry, so usually just add/subtract/divide/whatever my way to it’s correct position until it works. Aaaah.I love learning things before hand so I don’t have to scrap junk together like that in a hurry.
Always a big help. Thanks again.
-
Conrad Dsouza
November 4, 2014 at 7:39 pmHi Dan,
I’ve seen this expression many times, but I would like to apply it to a sightly different situation as follows : I have many words on different layers distributed randomly in 3D space; I have applied the “beam” plugin to a solid layer & would like to have it’s start point attach to the (x,y,z) anchor point of text layer 1 and it’s end point attach to (x,y,z) anchor point of the text layer 2; then repeat the same process from layer 2 to layer 3, layer 3 to layer 4 & so on. I have used AK’s SureTarget to animate the camera between the words already. The end goal is to show a line connecting one word to another as the camera moves between the words. Any idea how to convert the beams start-end points (x,y) to link with text layers anchor point (x,y,z)? Thanks.
Reply to this Discussion! Login or Sign Up