Skip to main content
Participating Frequently
July 18, 2022
Question

I need a genius...? 2D layer changes position when toggling 3D. How do I keep it where it is?

  • July 18, 2022
  • 5 replies
  • 1028 views

Hi there, I really need some help.

 

I have some handheld filmed footage of a wall.

I've succesfully 3d tracked it, and I'm able to add a null and a shape to the movement.

 

I want to obscure some parts of the wall, paint over it, add some details, etc.

So I exported the first frame of the video to photoshop, did my drawing on a new layer, exported that layer as a transparent png.

 

That png, when overlayed on the first frame of the video, looks brilliant.

Now I want to track it throughout the rest of the video.

All the tracking data is there, so it should be no problem.

 

BUT. As soon as I toggle 3D for this png, it jumps to a (seemlingly) random position, rotated in almost every direction, and scaled much smaller.

 

Do I now really have to manually figure out how much rotation etc is done, so I can put it back in place? (because all the values are 0.0.0.) That seems almost impossible. I've been trying, but I can never align it as perfectly as it was.

 

Is there a way (or a script) to keep a layer in the same place when toggling 3D? I know technically it probably should move to a different place, to make it appear in the same place, but WHERE exactly? Is there a script that calculates the difference between the 3D ground plane and the front view? Or something? SOMEONE? It's super frustrating. Thanks!

This topic has been closed for replies.

5 replies

Roland Kahlenberg
Legend
July 19, 2022

Place this Expression into the 2D layer's transform>position property. The name of the 3D layer this Expression is referencing should off course be changed to reflect the 3D layer you are intending to follow, in your comp. 

This only gives a representative 2D location of the 3D layer, without scaling/Z-position effects but it works well enough under certain use cases.

 

HTH

thisComp.layer("ImA3DLayer").toComp(anchorPoint)

Very Advanced After Effects Training | Adaptive & Responsive Toolkits | Intelligent Design Assets (IDAs) | MoGraph Design System DEV
Mathias Moehl
Community Expert
Community Expert
July 19, 2022

If you want to manipulate a single flat wall, a planar track with mocha is much easier and more accurate than a 3D camera track. See this tutorial for a clean plate workflow with Photoshop:

 

 

 

Mathias Möhl - Developer of tools like BeatEdit and Automation Blocks for Premiere Pro and After Effects
thepixelsmith
Community Expert
Community Expert
July 18, 2022

I may be missing something but, if you used the 3D Camera Tracker:

  • I would have made a flat Photoshop layer for the wall decorations.
  • With the 3D Camera Tracker effect active, you can select multiple track points on the same plane on the wall. This will give you a target icon
  • Right–click on the target and choose create solid. That solid will match teh plane of the walls surface and should stay in perspective as the camera moves through the scene.
  • change the dimensions of the solid to match photoshop layer.
  • Precomp the solid layer and "Leave all attributes"
  • Open the Precomp and add the transparent layer from PS into it. 

That should give you a graphic that matches the perspective of the wall as teh camera moves through the scene.

 

Mylenium
Legend
July 18, 2022

As long as it's a 2D layer, it has no 3D coordinates and there's really not much more to say than that. AE simply has no way of retaining the position since it never knows where exactly the content of the image would be in terms of depth. It only assumes default zero coordinates. This has nothing to do with it being mathematically impossible or any of that, it's just how AE works. Of course it would be possible to craft convoluted expressions with a ton of toWorld(), toComp(), fromWorld() and so on to calculate something, but you'd still need a point of reference and at the very least this would mean placing several Nulls in the scene to calculate a plane or intersection. Otherwise you may want to refer to the various "projection mapping" tutorials out there. You have to align something first or else you're flying blind. In the end it's really just a matter of preference at which point your texture gets unwarped and re-applied, but eventually that is part of every workflow regardless of what tools are used.

 

Mylenium

JoosstAuthor
Participating Frequently
July 18, 2022

Ah. It seems like someone made a script that does what I need:
http://www.renderbreak.com/2014/07/after-effects-script-keen_3dlayertools/

Namely: "Promoting 2D layers to 3D in the active camera’s view, keeping the apparent 2D positioning."

I'll see if it actually works, since you're saying it's impossible, I'm not sure.

Mylenium
Legend
July 18, 2022

Your logic is flawed and the workflow wrong. Exporting the PNG has already perspective baked in and it would be way too much work to fix any of that. the proper way to proceed is to unwarp the layer conventionally so that it matches whatever solid or pre-composition you have placed in your scene and then simply replace that. It's called reverse projection mapping. Since AE does not provide a way of direct texture/ projection baking, you have to kind of hack it by creating a solid that matches the area you want to cover, render this out as a reference matte and also export a still frame of your background. Then you use both in Photoshop to unwarp your image to a regualr rectangular shape based on teh reference points your matte provides. The same could be done in AE using tools like Bezier Warp, Corner Pin, Mesh Warp, CC Power Pin or advanced third-party plug-ins. Point in case: You realyl need to remove the perspective from the texture or else this becomes entirely unpredicatble and you'll work your fingers off trying to fix it. Only then can it be warped back using your camera tracker or corner pin 2D track.

 

Mylenium

JoosstAuthor
Participating Frequently
July 18, 2022

Okay, I see what you mean. But sorry, it's not a solution to my problem. It seems not very precise, because 'warping' in photoshop is by no means an exact science. It would mean I have to eyeball it. If I have to eyeball anything I might as well just eyeball my current png back to the edges of my screen. And I see what you mean by having to remove the perspective from the texture or else it will become unpredictable, but that's not really an issue here since the wall is super flat, and the tracking data is super precise. I can see the solid following the footage pixel-perfectly. If only it was in the right place...

I was hoping for an easy way to keep a 2D layer 'in place' in the current view when toggling 3d. That IS actually an exact science, because it can be calculated precisely. It's not a strange request, not flawed logic or a wrong workflow. Just a really handy missing feature. So I thought maybe someone could have written a script for that?

 

Or, any other advice?