11 Replies Latest reply on Apr 18, 2016 8:16 AM by Rick Gerard

    How to create a 3d fly through of photoshop layers

    Houston.Brown Level 1

      I have an image in Photoshop that has lots of layers. I want to take that layers, import them in after effects and create a camera that will fly through the layers just like in this Dave Hill video (Adventure Series - by Dave Hill - YouTube ) . I saw an interview with him and he said it was quite easy to do but I be darned if I can figure it out. I have watched a few AE videos on how to do something similar, but the main problem I am having so far is that after importing the layers into AE, the image looks nothing like it does in PS. I am sure that some layers will need to be combined in Photoshop to get the right look in AE but I am at a loss. Perhps tis may be way over my head as I am not an experienced AE user at all. Just thought it would be really fun to try.


      Any input would be greatly appreciated.


      Many thanks,


        • 1. Re: How to create a 3d fly through of photoshop layers
          Rick Gerard Adobe Community Professional & MVP

          There are two tricks to this technique. It is sometimes called "The Kid Stays in the Picture" effect.


          The first trick is that you have to separate your image into foreground, middle ground and background layers in Photoshop and fill in the holes left when you cut things out on the layers below.


          The second trick is that you import your PSD as a comp, then make all of the layers 3D, add a camera that has approximately the same focal length used to take the shot, then move the middle ground and background layers away from the camera in 3D space. They will get smaller as they are moved back in Z space but you fix that with scale. To make the perspective shift look natural you have to approximate how far these elements would be from each other.


          For example, if you had someone sitting in front of a window and there was a tree outside the window and there was a mountain behind the tree you would first duplicate the background layer 3 times. The background would be the mountain layer, the next layer would be the tree, then next the window, then the top layer would be the person.


          Now you cut out the person, then temporarily turn off the top layer. Now you cut out the window and erase the person where they were in front of the window. You do the best job you can. The more of the person you can remove the more you can move the camera. Then you cut out the tree and erase any part of the window that was in front of the tree. Again, the more of the window and the person you can remove from the third layer the more you can move the camera. The last step is to remove the tree and the window from the background so only the mountain remains. Again, the more of the other elements you can erase using what ever tools you need to, the more you can move the camera. Sometimes you'll have to cheat with scale, sometimes you have to borrow things from other images. It all depends.


          Once you have you Photoshop file prepared you Import as a comp, then add a camera and make all of the layers 3D. You start by grabbing the bottom layer and you move it quite a ways back in Z space. Now you scale the layer up until it fills the frame. If you want the tree about half way between the background and the foreground (the person) you move the tree layer back in Z space about half way between the foreground and the background. Now you scale up the tree layer until it looks right. The last step before starting to animate the camera is to move the window back in Z space. Since the window and the person are close to each other you only move the window back in Z space a little bit, then you scale the layer up until it fills the frame.


          Now you animate the camera. It's as simple as that. The more of the person and the window and the tree you were able to remove from the second, third and fourth layers, the more you are able to move the camera. The photoshop part is the hardest part.


          In the example you posted you can see all of the layers that he has used stacked up in Z space. Most of the time the layer's do not rotate but as he exposes the camera move sometimes he is rotating the layers.  It looks like he used some blend modes for the smoke. It's all pretty simple if you understand how perspective and parallax works.

          Screen Shot 2016-04-16 at 6.41.10 PM.png

          Personally I have never revealed the secret in any of the sequences that I have created that use this technique. I guess that Dave likes to show 'the man behind the curtain' When I estimate the time required for this type of project I devote about 80% of the time to Photoshop.

          • 2. Re: How to create a 3d fly through of photoshop layers
            Houston.Brown Level 1



            Thank you for taking the time to explain all of this. I have managed to get about 1/2 of what I am trying to accomplish. The problem I am having ow is that when I take on e of the Photoshop layers, convert it to 3D, then try and move the position (z) forwards of backwards, it also changes the scale of that layer. I need the scale to stay the same or else all the layers become misaligned. If you look at the first few frames of the example video, you notice the image looks as it would if it was flattened. then the camera starts to move through the layers everything stays in place. Only the layers have gaps between them which is exactly want. I am not sure how to move the layers through the z axis without scaling them.

            • 3. Re: How to create a 3d fly through of photoshop layers
              Rick Gerard Adobe Community Professional & MVP

              You scale them to match the frame size at the first position then you move the camera without changing scale. If the motion does not look right then the spacing is off. common things that cause problems are wrong focal length and incorrect space between foreground, middle ground and background layers. The ratios should match real life.


              If you tied the scale to the distance to the camera then there would be no change in image size as the camera moves and that would never happen in real life.

              • 4. Re: How to create a 3d fly through of photoshop layers
                Houston.Brown Level 1

                But what I am trying to do is to start off the scene looking at the image strait on so all layers so the image APPEARS to be flat (See video at 6 seconds). Then I mean to fly through the layers at which point it will be obvious that the layers will start breaking apart as you fly through them, just like in the example video. So, I have to be spread all the layers along the z axis but when you do that, each layers requires you to resize them to make them look like they are in the right perspective.  This seems an impossible task to do when you have to resize all the layers to match. It's like creating forced perspective on all these layers which to do by hand seems if not near impossible, certainly very time consuming and the interface does not seem to be conducive to such a task either. Certainly I am missing something.


                Many thanks,


                • 5. Re: How to create a 3d fly through of photoshop layers
                  Rick Gerard Adobe Community Professional & MVP

                  Lining up is very easy to do if you import your Photoshop file with Comp size instead of layer size selected for the import as a comp option. Then you can just add your camera, move the background back by adjusting the Z value, then select the scale property and scaling until the edges of the background layer reach the side of the comp. It should take you just a few seconds.


                  If you choose retain layer size then you just have to guess. This does not have to be absolutely precise. If you want it precise you can use and expression to scale the layer precisely to the equivalent of 100%. The expression looks like this:

                  C = thisComp.activeCamera;

                  CP = fromWorld(C.toWorld([0,0,0]));

                  L = thisLayer

                  LP = fromWorld(L.toWorld(anchorPoint));

                  d = length(CP, LP);

                  z = C.zoom;

                  r = d/z

                  r * value

                  You will then have either make a note of the scale value and disable delete the expression and enter the new scale value. The other option is to use the Keyframe Assistant to convert the expression to keyframes  and then delete the keyframes.


                  Let me repeat that you cannot leave the expression turned on. You will not get any 3D effect if you move the camera in  Z.


                  When I do this I always just import the PSD with Comp Size selected for the layer option and then just do the conversion visually. Holding down the shift key lets me drag the Z position value at 10 times the normal rate and makes this a very quick thing to do. I don't really worry about lining things up to perfectly match the original photo because eyeballing the edges of the frame gets you close enough for most projects.


                  The most important part of getting this effect to work well is the relative position of the layers. If you have a person that is 10 feet from the camera and a window that is 15 feet from the camera and a tree that is 150 feet from the camera and a background that appears to be a mile from the camera you need to set up those relationships in AE. If you have picked a focal length for your camera that closely matches the focal length of the camera used to take the photo then the objects in the frame that meet the edge of the frame would be at the default position. Let's say that was the wall that contained the window. If the zoom value of the camera was 900 pixels then the wall would be at a z value of 0 which wold be the equivalent of 15 feet, then the person would be at 1/3 closer to the camera or a z value 1/3 closer to the camera or -300. The tree would be at a z value of 10 times the zoom value or a z value of 9000. The background will work if it is two or three times that value or a z value of 27000. This will get you close and make the camera move fairly closely match the perspective change you would get in real life.


                  The numbers are approximate and don't have to be perfect but the ratios should be close. If you distribute the three layers evenly in Z space you will still get a perspective shift when you move the camera, it just won't be accurate but that stylized look may be just what you are looking for.


                  If you wanted to move in on the layers so it looked like the photo was flat you would set up the comp so you had the original photo as a 3D layer in the same position as the foreground ground. In this case you would want to use the expression to precisely scale the layers so they match the original. Then you would start your camera move and simply cut to the other 3D layers when you wanted the separations to start. You would make the cut when you want the foreground to start moving closer to the camera. This will take some pre-planning and some calculation.

                  • 7. Re: How to create a 3d fly through of photoshop layers
                    Houston.Brown Level 1

                    I think I am getting really close. One of the problems I was having is that the PSD was way too big that I was bringing into AE, over 6000px in the horizontal. I have resized the image to 1920 X 1080 and that seems to work better. But now I am getting a problem with pixelation. Is this because my image that I am importing from PS is too small. I would think there is plenty of resolution as i am not scaling anything up.


                    Screen Shot 2016-04-18 at 8.15.55 AM.png

                    • 8. Re: How to create a 3d fly through of photoshop layers
                      Houston.Brown Level 1

                      Ivo, thank you for the tutorial link. I had found several examples of what I am trying to achieve but none of them really went into any great detail about how to scale things to make the the correct size once you moved them on the z axis. This one did. Wish I had found this the other day. Also, Rick has been a HUGE help in this thread.


                      Many thanks,


                      • 9. Re: How to create a 3d fly through of photoshop layers
                        Rick Gerard Adobe Community Professional & MVP

                        To properly size your master image you have to consider what part of the image you want remain sharp and in focus when the image is moving slowly. If the image is moving quickly you can hide the scale problems with motion blur. If you are simulating depth of field you can also hide things with blur.


                        For or example if you wanted to move in on your sample image of the girl to show her head and shoulders before motion blur or depth of field started to blur the image in a comp that was 1920 wide then you calculate the image size like this. The girl's head and shoulders are about 1/5 the width of the entire image and the comp is 1920 pixels wide so the image needs to be about 1920 x 5 pixels wide. That is 9600 pixels. If the original image was only 6000 pixels wide then you need to adjust your design a little bit and not push in quite as far before you start to blur the image.


                        Does that make sense? If a layer at 100% scale is exactly the zoom value of the camera away from the camera the images at 100% scale.  If the images scaled 200% then the distance from the camera must be twice the zoom value to maintain an effective 100% scale. At some point in your composition you want your layer to be somewhere close to an effective 100% scale. If the layer is moving you can get away with 150%, but anything closer to the camera than that requires motion blur or depth of field to hide the pixels.

                        • 10. Re: How to create a 3d fly through of photoshop layers
                          Houston.Brown Level 1

                          I guess I will continue to refer to the video in my original post. As you fly through his image, all the layers are quite sharp. Just trying to figure out how he accomplished that. If I import the original PSD file, the render to view my work as I go along takes forever. That may be a whole different issue I am sure.


                          Many thanks,


                          • 11. Re: How to create a 3d fly through of photoshop layers
                            Rick Gerard Adobe Community Professional & MVP

                            His images stay quite sharp because he uses the techniques that I described in my previous post of making sure the images were wide enough to start with.


                            For example this shot starts here:

                            Screen Shot 2016-04-18 at 8.01.08 AM.png

                            And pushes into here before the image starts to soften:

                            Screen Shot 2016-04-18 at 8.02.29 AM.png

                            So hi is pushing into about 1/4 of the image before it starts to soften. If the comp was 1920 wide then the image of the girl needs to be about 1920 X 4 or 7680 pixels wide. It's very simple. As the camera gets closer the image softens a bit more until you get to the final position.

                            Screen Shot 2016-04-18 at 8.08.45 AM.png

                            Depth of field or a little camera blur softens the edges a bit more and hides the pixillation but it's there. You just have to follow the rule so that the image is somewhere close to an effective 100% scale at some point in the composition. To keep the image of your girl from falling apart you just have to deal with the longer render times from the bigger image.


                            You can go a little farther if you use detail preserving upscale to resize your layers before moving the camera in, but that will only buy you a little bit of increased sharpness.


                            I did a project like this a few years ago where most of the images were 15,000 pixels wide because we had to push in a long way. Fortunately we had very high resolution originals that were drum scanned from original photographs from the 1930's to work with. If we were stuck with the 10 MP images from my DSLR at the time we would not have been able to move in as far.