ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

# connecting layers with a real 3d line preserving dof

FAQ   •   VIEW ALL
 connecting layers with a real 3d line preserving dof on May 18, 2018 at 9:37:33 pm

hi everybody.

I am trying to connect 2 layers (A,B) with a line in real 3d space, because the trick with the beam effect and the toComp expression doesn´t work with depth of field.
I have drawn a shape layer line from [0,540] to [1920,540], made the layer 3D and set the anchorPoint to the left end[-960,0,0].

Then I connected the position of the line to the position of Layer A, set the correct scale of the line via the length(A,B) expression.

Now comes the tricky part. For the orientation i set:
end = thisComp.layer("B")
end = end.toWorld(end.anchorPoint);
lookAt (position,end);

When I now set the y rotation to -90, I get pretty close to what I want. The line connects the two layers correctly in 3D space.
But when the two layers come close to each other in x position, the line layer gets thinner and thinner until it finally disappears.

How can I adjust the oriantation expression to also have the visible side always orientated towards the active camera?

Thanks so much..

 Re: connecting layers with a real 3d line preserving dofon May 18, 2018 at 11:37:59 pm

My 2 cents...
check you are only scaling your x direction and not the y direction.

Right click on layer
transform
auto orient
Orient to camera.

 Re: connecting layers with a real 3d line preserving dofon May 18, 2018 at 11:54:23 pm

thanks for your help, but its not the solution.
i scale only x axis, thats fine.
but when i turn on auto orientation, the expression on orientation does not work correctly anymore and the two layers are not connected.
So I have to implement "orient to Camera" somehow in the existing orientation expression, but it seems to be quite hard 3d rotation math. here are three images demonstrating my issue:

 Re: connecting layers with a real 3d line preserving dofon May 19, 2018 at 3:29:16 pm

I think the problem is that the "visible" side cannot always face camera because it will always be on a perspective angle between the far circle and the front circle. The beam layer, made 3D, is just a flat plane that has been angled back, so its Z vector is pointing up (or down) and to the right or left. If if always faced camera it would never have any perspective - the planes "normal" would always point dead into the lens.
What's happening in your case is classic gimbal lock - as an object rotates in two axis, at some point the angles add up to an angle AE will want to represent another way and the object will flip. And you can end up viewing that object edge on - which is why its disappearing (the Beam effect has no thickness)

Trapcode's 3D stroke would solve this. TC3D strokes have thickness. You apply the strokes to a 2D plane and then the render engine puts them in as close to true 3D as you can get in AE. And you can connect the ends of the "beams" via expressions to the anchor points of any 3D planes and they obey both motion blur and DOF rules in AE. But it costs of course.

I just tested Video Copilots Saber plug in (its free). You can get it to do the same through toWorld expressions because the beam is only 2D (like the Beam effect) but with it being only 2D (but looks 3D) you can't easily do the DOF.
What about using a DOF map generated by your scene but used in another comp to get the blur on just the beam itself?

I'm trying to think of a way to have the beam layer point at something else in the scene so that its face is always visible "face on" even though its on an angle to the camera. Think of a cone - the tip is connected to the front most circle and the back most circle is connected to the outer edge of the circular base of the cone. The beam plane would lay along the surface of the cone with the normal of the beam plane aligning the cone's angled surface normal.
Since you are animating the two hero circles you could add a 3D null and have the beam plane point at that, and then just animate the null in 3D space at the same time you animate the circles (or the camera) to keep the plane's face at a decent angle to the camera.

 Re: connecting layers with a real 3d line preserving dofon May 19, 2018 at 3:49:58 pm

hi Steve
The last thing with the cone I didn´t understand right away and have to think about it.

But what I am actually trying is to connect a shape Layer stroke in 3D space, not a layer with the beam effect (but this should be possible too)
Here is my project file:
12401_connectionlines3d.aep.zip

I am really sure that there is some math to resolve my problem, because I can always, if the layer seems to dissaper because you view it from the side, just manually adjust the z value of the orientation to face it back to the camera and everything is fine again.

So there must be some math to put in the orientation of that layer to get everything work, but I cant´t figure it out because this 3d rotation stuff is tricky.

 Re: connecting layers with a real 3d line preserving dofon May 19, 2018 at 5:51:36 pm

You may have to nest the plane inside a null to remove any gimbal issues. Use the null to adjust the Z only

 Re: connecting layers with a real 3d line preserving dofon May 19, 2018 at 8:21:40 pm

Sorry, I meant: use the null to add extra control (or all of the control) to whichever axis controls the angle so that the plane never goes edge-on

 Re: connecting layers with a real 3d line preserving dofon May 19, 2018 at 9:27:34 pm

I understand your point, but I don´t think I need an extra null here, because in my setup I can adjust the orientation z value so that the plane never goes edge-on.
The problem is how to set this value correct automatically, because when I copy this layer a lot of times connected to randomly arranged circles, i cannot do this manually.
This same problem I would have with an extra null aswell.

 Re: connecting layers with a real 3d line preserving dofon May 19, 2018 at 9:50:54 pm

to adjust the z value manually just add "+ value" to the orientation expression, but how to calculate the perfect value?? I think about this for many hours. Any ideas??

end = thisComp.layer("B");
end = end.toWorld(end.anchorPoint);
lookAt (position,end) + value;