Add 3D Effects to Your Photos with Camera Projection Mapping in Blender 2.8

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this tutorial I'm going to show you how to add 3d camera moves into any photo to do this we're going to be using blender 2.8 Photoshop and another free bit of software called EPS buy before we get started you'll need to go into the description below and download F spy from the link and install it and then once you've done that fire it up and let's get started so when you fire up F spy this is the screen you'll be greeted with all you need to do is just drag and drop your image that you want to use into the interface I've provided this particular image in the description so you can follow along exactly with me or you can just use any other photo that you like I'd recommend if you're starting out and probably start out with like seedy scenes because there's a lot of straight lines and that helps with the camera matching but anything any photo will really will do so I'm just going to turn off this dim distance here just to help us see the image of it better so as far as f spy is concerned there's two kinds of images that it will accept one of them is a single point perspective and one of them is a two point perspective and I'll show you some examples here of one and the other so based on that we can see that this is a single point perspective image we know that because we've got these straight lines here and they all kind of converge at one single point in the image so that means up here where it says number of vanishing points we just set that to one to make life a little bit easier later on I'm actually going to switch these axes here so number one axis will be Y and number two axis will be X and the focal length we know from the photo is 70 because that's on the website actually where you download the image so that's nice and handy to have that but you can get away with not knowing it and just leave it on the defaults so what you need to do now is just drag these handles and just line them up with any kind of parallel lines in the photo so of course the street scene is nice and easy because we can just point these line along the street here I mean you could if you had straight lines along here you could put one here and one here something like that you know but in this example our kerb here is pretty straight so we'll just use that the second axis for a single point image is basically kind of your level so you want this to be lined up to any straight lines in your photo that are actually kind of they look like they're level in this case the front of this curb I think will do the trick so let's just do that cool okay so you've got also this little point here and you can just put a like a grid attached to it and you can kind of just drag it around check the perspective looks right so that seems pretty good the other thing we can use this for is measurements so we'll grab this we'll put it at the bottom of her foot here and then what we'll do is just set our reference distance here to be along the z-axis if you turn this dim image back on you can see the little handle here that's appeared and so you basically set that to what you want to measure so it'll be we'll just try and guess her height here let's call it 1.6 meters now last but not least we just need to place this origin point here where we want the origin of our world in blender to be so usually it means you probably want on the ground somewhere for this scene in particular I think we can just put it over here at the corner of this curb and I've had to move that handle out of the way so I can drag the point so I'll just drag that handle back down and that all looks pretty good so let's save it go file save as and then that file is ready to go into blender alright so here we are in blender let's just delete everything wrong key X delete cool but what you'll need to do first is go to the s buy website download the apps by importing add-on for blender and install it so once you've done that you will have if you go into the file menu import and you'll have an F spy option right down the bottom here now we just go and pick our scene that we saved earlier and there we go now to make our life a little bit easier what I'm going to do is split this bottom window and this is going to be our shader editor and then I'm gonna split this top one here as well and this can just be a general 3d view and this can be our camera view cool alright so let's start off with the ground we'll add a plane scale it up we just want to basically scale it so it kind of matches the ground in the photo so something like that looks good now there's a couple of different ways that you can do camera projection in blender one of them is if you simply just go in the viewport going to edit mode push you and then hit the project from view and so that basically just will create UV coordinates for your object based on the camera that's all cool right but the way I like to do it is actually with the modifier the modifier basically it keeps everything procedural which I like and it also is real-time like it updates in real time and I'll show you what that means now because this projection technique is based on UVs it's is influenced a lot by the amount of vertices you have in the object so a good way to kind of help with that I suppose is to actually add a subdivision surface but you set it to this simple mode here so that if you just go into wireframe we turn this up it doesn't kind of smooth your object as you subdivide it it just adds more faces so that's good that's what we want and so then the next modifier you want is a UV project and we're gonna pick our camera here and actually before we do that let's name it something that makes sense and I love this f2 you can just push it and rename stuff because I like keeping things clean let's call this proach prod cam for projection camera click on a plane again and then we'll pick that again okay so that's good now to test this we're going to make a quick little shader here we're just hitting the new button we don't want this principal shader you'll get this gigantic node here just X to delete it we will name it BG this is our BG image so the way I like to work with the node editor is actually just shipped a enter and then you can just type stuff for whatever node you want so you can just type a mission and if you push enter and then enter again it'll drop that node down so we want a mission we want an image texture I think that's it yep let's do that so output of the mission goes into the surface image texture color goes into a mission now this little drop down here on the image texture is what we want and we're just going to pick this scene dot F spy which is our image okay cool now nothing's changed here because we actually just need to set this to be looked at mode so that the textures will show up and so we'll do that here and we'll do that here as well okay so yeah it's kind of looks like it's working but you'll notice these they all kind of look a little bit wobbly like everything's a bit kind of distorted so this is what I was talking about the whole vertices thing right so to fix that you just go into the subdivision modifier here and you can turn this up and you'll see as we go up higher and higher the distortion starts to go away the only other issue with this though is you'll notice we're getting pretty high level of detail but it's mostly in the kind of horizontal axis and not the vertical so I found the best way to fix this is actually just add in some edge loops and we'll do this in solid mode so we can see it a bit easier and I'll just make this fullscreen so if you tab into edit mode ctrl R and then you can add some divisions down the street and you want to kind of you want to get the faces to kind of be almost like a square as you can get them so let's do that that looks pretty good escape so we don't move them and then we tap back out of edit mode and now what you'll see is we can actually turn this viewport setting back down and if you look here in the wireframe mode now we have a bit more sort of even distribution of faces and that's seems to be working pretty well here also one thing you got to remember is if whatever you adjust in the viewport setting here you'll also have to put that setting in to render otherwise it will render with all the messed up version instead now one other thing the eagle-eyed people will notice at this point is it looks like the image is a bit wider than the actual source image if you hide this you'll see this is what it should look like but then this is how it's being projected what you'll need to do is go into these settings here and adjust the aspect because the the projection modifier doesn't know what the aspect ratio of your source image is so you can just eyeball it like this you know use this scale X and bring that in here zoom in to check it ok so 0.88 3 is what we have here all of these modifiers all of the UV projection modifiers that you use on all of your objects will have to have this same number plugged into there so whatever it is just take a note of it and then you can just put it into all the objects ok so let's at this point quickly save our scene before anything crashes cool all right so the next step that we're going to do is we'll make these sides of the streets here now the amount of stuff that you want to model is really up to you like you could go crazy and model every single tiny little thing all the trees or the bamboo or the all everything right but I say start simple and then have a look at the results and then decide from there okay I'm gonna have to model this I'm gonna have to model this or whatever so that's exactly what we're going to do and I'll show you how all that works and then that will help us decide what we need to cut out in Photoshop and what we need to build in 3d in blender so we're going to make a an object here which is a card and this is just going to be a generic object that we can use you know we'll just duplicate it and use it as kind of a base object for the rest of our scene so add a plane and then our X 90 to stand it up GZ 1 2 put it up onto the ground plane and then we just want to go object set origin origin to 3d cursor and that will just move the center point of our object onto the ground here so that whenever we do a scale or anything like that it'll just scale around the ground point here so that'll be very handy while we're at it let's add our modifiers now remember we need a subdivision surface with the simple turned on we'll turn it up to 2 to start with then we also need a UB project pick the camera we can also just grab that material as well if we want to see what we're doing no not that one the other one okay that's cool so if we move this around we can see projection is working let's rename this call it card good yep and then to make everything else we're going to just be duplicating this object here so shifty push escape we'll pick this other card and hide it and then just grab this we're going to are there 92 move it to be along the street here and we'll just scale it and fit it into place so it covers this side of the street okay that's looking good now again because we've got our because of the subdivision issue we'll just have to go in here so tab control our make out faces square something like that and then back into this view here we'll just turn up our subdivisions until everything is nice and straight and not wobbly at all against it render to be the same let's save cool that's one side of the street let's shift the duplicate lock it to X drag it across to the other side now I've forgotten something and that is our little scale X here so point eight eight three copy that paste it here paste it yeah and in fact on our regional card and let's paste it there don't have to worry about that again okay and this is another cool thing you'll see with this kind of procedural approach to the projection is now I can actually just move this card back and forth and I'm just moving it along the x-axis right and that's we can just line that up you can kind of see the curb here you can just hold down shift and just line that up like that in the viewport that looks pretty good and one last thing let's grab this tab push number two to get into edge mode and we're just going to extrude this edge along the X to be that just that front of the curb here cool all right now we're getting somewhere of course lift name stuff now the next step is we want to put in just a test camera like a test animation in the camera this will just help us to kind of work out bug fixes I mean if you want to work out exactly what you can remove is at this point awesome go for it but for this test we're just going to do something nice and simple so what we want to do is because we don't we can't actually move the projection camera because you'll notice if you do the whole projection moves which is a pretty trippy effect but it's not really what we're going for so let's shift the duplicate that name it of course and this is going to be our render camera and then just in your seam settings here in your camera call this render cam instead of projection cam so now this viewport on the left here is now looking through that render cam and we're just going to go down here set this to a hundred frames long push home to reset your frame range here and then we can just make a quick little animation so here push I set a keyframe and then go to the end that's G Y push this will go pretty crazy we'll push right in here just to help us visualize a bit better exactly what we need to fix in Photoshop so that's all good with these key selected like they'll be both yellow here just go T set it to linear because we just want a linear move and there we go we can make this big so now you can see looking at this exactly what things we need to cut out and essentially it's the things that are distorting right so these the girls here are on a kind of separate plane to the street and so the bottom of their legs are starting to distort let me just draw on this year so these these legs here starting to distort as you as it moves through the frame the bottom of this pole here is starting to distort even and this sign as well you can see it sort of starts off straight and then as it moves along it kind of gets a bit distorted so at a bare minimum I would say they're the three things that we're going to have to basically go into Photoshop and cut them out and then we can map them onto separate objects can be just a card in the scene or whatever but that will just stop those kind of distortion effects happening and it'll also add a lot more depth than dimension to the photo because we'll get a bit of power likes going on all right so here we are in Photoshop I'm just gonna run through cutting out the women here and then you'll be able to basically rinse and repeat for the other objects like the pole and the sign so what out the way I like to do it is select the selection brush here and the left and then in 2019 I think this is new in 2019 there's a select subject button so you can kind of roll the dice if you like and hit the Select subject and see what happens in our case perfect well not quite perfect if we zoom in here it's done a decent job but you'll want to just get in here with the selection brush and add and subtract to the selection to get a bit better result you can use Alt key to subtract from the selection but as you can see it's done a pretty pretty decent job straight off the bat another way you can refine this as well as if you go into the Select and mask feature button here you'll actually get kind of a new sort of window that'll take over the screen and you can use this as well to kind of add to the mask and so on I like to work with the this view mode here to set to overlay so you get this nice kind of red color here that you can really sort of see the difference between what you're cutting out and the background and so then it's just a matter of you know going through here we're still in the selection brush it tries to work out you know where to select and stuff I find maybe at this stage you might want to just hit the normal masking brush here and just go through and clean up a lot of these edges now you don't have to be perfect here and in fact I would just say you want to get something kind of rough working and then you can always go back and tweak when you're ready later so I'm just going to go ahead and clean this up now and once you're happy with what you've masked out the I find the best way to do this is if you go into output settings no yes output settings go output to new layer with layer mask and so that way when you hit OK you'll actually get this new layer with the layer mask light as it says so I like to do this because it'll keep everything you know non-destructive and it means you can go back and edit the mask again quite easily so that's one layer here I'm just gonna go through and repeat the process for the other two items that we were going to cut out which is this pole and the sign and just to bring the point home at this stage we're really not looking for perfection you can see this sign here is pretty rough right so I definitely plan on going back and refining everything later I think I think it's important to kind of just get everything into the scene even if it looks rough because sometimes you might not need to really refine things depending on the end result you know so this is a great way to kind of work a lot quicker and then all you have to do is go back and refine the things that you need to refine rather than trying to make everything perfect straight away okay so we've got our three layers here I'm just going to name them real quickly and let's take the opportunity now to just get in here and save our file what we'd like to end up with is a layer for each object that we want to map onto a card and we want to have a background layer with all of those things removed so to do that all we need to do is for each item we want to remove we can just control click on the layer and that will give us a selection based on the mask for that layer give us each selection needs to have a little bit of a border like expand it a little bit so we'll put in like 20 we'll expand that out so we just need to give it a bit of a margin for the content-aware fill to work best and then we just go here content-aware fill and let's bring our preview window up a bit so we can see a bit better what's happening and if you don't see this exact screen like this this is brand new I think for 2019 so you might not get as many controls as this the tool basically works the same kind of way you just won't be able to do this next step and that next step is basically you can tell the content aware fill with this new tool what you want it to consider like what parts of the image you want it to consider in the filling of the area that you're trying to get rid of so you can see here for instance that there's this this kind of sign has been kind of replicated over here this lantern as well has just been replicated so you can tell it okay I don't want the sign and then it's gone I don't want this lantern and I'm just painting with a left mouse button here and it's you know it's still not perfect but again we're not really aiming for perfection at this point we just want to get something kind of roughed in to a half-decent kind of level of quality and then we can always go back and refine things where we need to because sometimes this might be good enough depending on how much of the background that your camera move is revealing this might be fine for what we're doing so let's not get too carried away at this stage but again what we're going to do is we want to make sure that this is outputting to a new layer so that we can keep everything non-destructive and it's easier to edit later okay so there we go that's removing those guys and then again as as before it's just a matter of rinsing and repeating okay so let's have a look at the layers that we've made so we've got here three layers called delete and if we turn all of those on this is our clean background plate so let's export this we've got export as and we want to PNG but we're going to turn transparency off for this one so then we just go export we'll call it background okay that's one down so now we want to just turn off everything and then each one of these layers it's going to get exported so we've got our sign selected here let's go file export export as and for these layers we actually want transparency to be turned on so go export all we'll call this sign and then just go through and do the other layers okay now don't forget to save as usual and now we're gonna go back into blender okay so in blender first what we're going to do is let's pick our existing background shader here and we're gonna replace this image with the BG background image that we exported out of Photoshop you can just hit the X to bin that off push open here select BG and this is our clean background so now we have a nice street scene and no distortion while we're at it you'll remember the little card object we made before so we're just going to duplicate that we're going to need a card just to cover up the bar background in our image here okay that's done let's rename it and let's make a card for the women in the middle of the street here so again duplicate our existing card shift the kind of move it to around where they're standing in the scene and let's just hide our original card and name this one now we're going to want to make a copy of our BG shader because we're actually going to do some modifications here to enable the transparency so let's just hit this duplicate button here and walk name it women again we'll hit the little folder icon here and then we can pick the women image and so straight away you can see the problem here obviously there's no transparency by default so that's all cool we will set that up right now so we're going to need a couple of additional nodes let's add in a mixed shade up and we're gonna add in a transparent psdf now the transparent has to go in the top in the top shader slot here the emission goes in the bottom shader slot the shader output goes into our material output here and then we want to pull the Alpha from the image and that will go into this factor setting here we've done all that and you want to notice it's still not doing a transparency because we actually have to tell Eevee that we want we've got transparency in our shader and we want that to be considered in the render you can just go to options tab here and this is in the end panel on the node editor and then you just need to change this blend mode here from opaque to alpha blend and there you go the cool thing about this all being in 3d is you can actually look on the street and see where the shadows for the for these guys are so that just makes moving things around a whole lot easier because you can kind of just pick this position here looks about right I think this lady in the pink is a bit further forward than the others so you can kind of rotate on z-axis we need to scale the card up a bit because they're getting a bit cropped one thing you want to be careful of is anything any cards 3d objects that you place in the scene you want to make sure that if they sit on the ground that the actual point where they touch the ground is fairly accurate in 3d space otherwise you are going to get some problems with like the feet sliding or stuff like that most of the time you might be able to get away with just making cards like we've done so far but you may have to depending on what the object is the shape and stuff you may have to do a little bit of modeling to make that actually fit properly so let's just have a quick look at our scene now and we can play the camera back and we can look here and it looks pretty good the contact of the feet looks pretty good doesn't look like this sliding too much but you can see already that the the 3d effect is really starting to take shape so now we're just going to rinse and repeat for all the other objects like the pole and the sign and we'll come back and have a look so everything's in there now it's all looking really good I mean even with our rough kind of cutouts and stuff you can hardly notice at this stage I mean maybe when we render you'll be able to see something but for now it's looking great so let's get this ready for rendering when you import the scene from with F spy it actually sets up your resolution to be the same as the source image now usually you don't want that I mean you know if you want to render a 3000 by 4000 and go nuts but we're gonna set this to something a bit more sane we can do let's do Instagram resolution because that's what everyone really wants right 1080 1080 this is our square Instagram resolution now one thing to check is if you just go to frame 1 you'll see here now that we're seeing a bit of like outside of the image here so that's a bit annoying we don't want to have to go in and adjust animation and stuff like that and you don't have to all you need to do is just go into the render camera itself and you can actually just adjust your field of view here which is your zoom and that will and use that to kind of just crop into the image where you want it so that's something like that will do the trick and then when we play it back that's looking fantastic now let's hit f12 and do a quick test render now so one thing we've got here well you'll see this the lady here has been cut in half so what's happening is we've hidden our template card here in the scene but it's not hidden in the render what you have to do is go into this little filter icon click the camera and then you'll get access to all of the little render flags and so then you just need to turn that off for the card hit render again and it's gone out of the render so that's it guys thanks for watching if you liked the video hit the like button if you liked the channel hit the subscribe button and we'll catch you next time
Info
Channel: Dylan Neill
Views: 503,399
Rating: undefined out of 5
Keywords:
Id: dHXRrpG_oSk
Channel Id: undefined
Length: 30min 55sec (1855 seconds)
Published: Fri May 31 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.