In this tutorial I'm going to show you how
to take any image, in this case we're going to be using this one right here. And we're
going to take it and turn it into a photorealistic 3d scene. So we're going from photo to something
with depth. And the technique we're going to be using is very popular, it's called camera
mapping. Some people call it projection mapping. And the basic idea is we need two things.
We need a camera that pretty much matches the camera this photo was taken with, so the
perspective and the view is lined up. And the second thing is we need the geometry of
the scene, so in this case we need a floor plane we need three walls and we also need
a ceiling. So in this case it's super easy because it's just a giant box. So we need
our camera and our box. And the first thing we do is we do the camera alignment and you
can do this in blender right away, however, it's very difficult to tweak and get it to
look like it was taken from the correct angle. So the best way to do it is there is a free
program. The link will be in the description. It's called fspy or fspy I really don't know
how to pronounce it. So you download this free program and also a free addon for blender
so you can import the files from fspy which is what I'm going to call it from now on.
So once you download it, link in the description, we're going to open it here. And then what
we need to do is bring this photo into fspy. I really hope that's right. What we do is
we take the ceiling photo, we bring it in. Ok so here is our interface. First thing you
might notice is that everything may or may not look super dark. If it does just go to
dim image and disable this. So we can actually see what we're doing. And then the idea is
we're going to take these lines, red being the x axis, y being or sorry green being the
y axis, and then blue which we can enable down here being the z axis. We're going to
take these and we're going to line them up to our photo. And then the software is actually
going to know where the camera should be. So let's start off with our x axis and I want
this to be horizontal across the photo. So we're going to take one of these and we're
just going to line it up against this wall. So something like this. And then we want to
finetune it so you're going to take this and hold shift. And that's going to let us zoom
in. And make sure that you do this as accurately as possible because the quality of our camera
is going to be determined by how accurately we do this. So here we have one of our red
lines. And to do the other we need to make sure that it's parallel to this x axis. So
we can actually put it up here or along the carpet which is what I'm going to go for.
So we're going to put one here again holding shift. And then the other somewhat over here.
Let me make sure that's aligned. So once you're happy with this you want to move on to the
other axis, in this case the y axis. And that's going to be perpendicular going along here.
So we're just going to bring this over to the wall. Just like that and then the obvious
other option is going to be the other wall. So this scene is very very simple. Other scenes
might have, you might have a bit harder time actually finding what you should be using
for your lines. But generally every scene will have something. Ok so once you're happy
with this we actually want to see the quality of what we did. So go to 3d guide and change
it from off into xy grid floor. If you didn't use x and y, you used x and z then go to xz.
So we used x and y. So we're going to enable this. We're going to bring this dot down here
and you may or may not see anything. If you don't that means that there is a vanishing
point error as you can see right here. And that basically means you need to do a bit
more tweaking like we're doing. And you see this ground plane is popping on and off. Think
this line is the issue, ya there we go. And since this is so sensitive to where we put
this basically that means we should pick a different spot because this isn't very accurate.
So I'm just going to pick this line over here. Because it's easier to see. Something like
that. Make sure our y axis is well defined. And again make sure that you do this as accurately
as possible. Ok let's adjust this line over here. Move that all the way down here. And
then you see that we're getting a floor plane that is lining up pretty well. And you can
put this wherever you want. I'm going to put it about here. And again you can do a lot
more tweaking you can actually find out the focal length of your camera from this picture.
You just enable this but you need to know what camera you're using. In this case I actually
don't know what camera was used for this photo so I'm just going to ignore that. But then
once you have your ground plane and again you might have to tweak with it if your vanishing
point has a calculation error. Once you're happy with this go to file, save as, and then
we're just going to name it in this case camera map. And then you're actually done with fspy
so you can close that and open up blender where we're going to import everything. So
again make sure that you have the free addon. You can make sure it's enabled by going to
edit, preferences, addons, and then just typing in fspy. In this case I actually already have
it imported and enabled. So make sure that's the case. So we're going to take everything
a. And we're going to delete it with x. And then we're going to go to file, import, and
you're going to see that we have a fspy option with the addon. And then just find our camera
map. And you see it's already imported everything. And basically all this is is a camera with
a background image. So if you go to your camera settings and go to background images you can
actually edit this. You can make it less transparent like that which is what we're going to do.
And then what we're also going to do is shift a to add a plane. Just like that, and you
see it's already matching. This plane looks like it's flush with the floor. Ok so that's
good. Also something that you might notice is that everything is upside down. As you
can see if that's the case what you can do is I'm just going to select all my objects,
rotate it along the y axis by 180 degrees. But then something that we also need to do
is bring this up. And you can also do some stuff with the 3d cursor to do this but this
is much faster. I think I am happy with this. Yes, everything still matches. So now what
we need to do now that our camera is matched up, the next step is reconstructing our scene
using geometry. So we're going to take our plane, we're going to go into edit mode, and
then we're just going to drag these edges so that they go along the floor. So we're
going to go 2 for edge mode. And then we can actually zoom in and then g x and just bring
that there. And this should be pretty accurate like when we bring our edge it should line
up. And that depends on the accuracy of what you did but we did a pretty good job. We're
going to bring this back. And then we're going to take this and bring it forwards. Once we're
happy with that and we have our floor plane I'm going to select this edge, this edge,
and this edge. Click e to extrude and then right click to move it back to where it was.
And then g z to bring it up. And that should be lining up pretty well, you can see that
there is a bit of error here but we can always fix that later. Make sure that you line this
up to the best of your ability. So this is pretty good, we're going to select two edges,
this one and this one and click f to fill in our ceiling. And then the last thing we
need to do is select this edge, this edge, let's actually exit out of camera, this one
and this one and then just bring them back a bit. Ok so we have reconstructed our scene
pretty easy. So now let's actually project our textures onto here. So I'm going to go
into object mode, go into shading. I'm going to make a new material and we don't actually
need any principled bsdf or any shaders at all really. We're just going to import a raw
image into the surface here. But you can also add shading if you want. So shift a, go to
texture, image texture. And plug this in here. And then all we have to do is put in our photo
inside this image texture. So navigate and find that. There we go, and you see that everything
is looking pretty messed up. But we need to do is project this texture from the perspective
of this camera. And there is a couple ways to do that but my favorite way is as follows.
Let me go into rendered view. So select your geometry, I'm just going to call this, I'll
call it room. Select your room object and then what we're going to do is go to modifiers
and add a uv project. Which is exactly what we want. So we need to click a couple things,
first of all we need a uv map. I'm just going to use the default one. We need our projector,
where it's going to project from and that's being this camera. So select your camera and
you already see it's looking a lot better. Still really distorted but a lot better. First
thing we need to do is this aspect right here, this is assuming it's a one by one image which
it's not. It's not like a 100 by 100 or 1500 by 1500. We actually need to calculate this
aspect but that's super easy. We're going to go to our photo and go to the properties.
And you see here it's 3264 by 2448. I'm just going to open up a calculator and all you
do is divide these numbers. So 3264 divided by 2448. So our aspect ratio one point three
repeated. So we're just going to type here let's do four threes, one two three four.
So already looking better but still some heavy distortion. And basically the trick here is
our uv modifier depends on how much geometry we have. So here we only have, let's see,
we only have five faces. So to get this to be more accurate we need to add more geometry
without changing the shape of this. So that basically means we need to sudivide. So we're
going to add a modifier, add a subsurf. And we're just going to bring this up but you
see it's actually changing the shape. But this looks kind of cool actually. But if you
don't want this just change this to simple mode like that. And then you can bring this
up and you see the distortion is going down. Let me just bring this back down so you can
see. This is original and then bring that up. And you want to make sure your modifier
stack is in the right order. Moving this up is not going to give the same results as down.
And in this case we actually want it up I believe. Yes, and you see that it's looking
distorted from this view but that's actually what is going on. So here is what we got,
we can go to camera and everything lines up perfectly. And now to actually see the results
of what we've made, let's take this camera and put another camera inside of here. So
not from the projector. So shift d to duplicate, right click to put it back, and then g y to
bring this in. Ok so this is our new camera we're going to call this the viewing camera.
So this is viewing and then you just want to do, when you go into camera mode it's the
same camera. If you want to switch it go to view, cameras, set active object when you
have this selected. Go to view, cameras, set active object as camera. And now we have this
like that. Let's go back into that. And we can go to, we can hit n to open some settings
and actually rotate around our 3d scene. So this is actually truly 3d now. Which is pretty
cool. We can go into cycles render and do some trippy things which I think is a good
idea. Ok so we are in cycles and I think something interesting to do is to add a giant mirror
in the middle of this. So we're going to go shift a, mesh, plane. Make that big, and have
it kind of cut through our surface here. So you can see now we have a true 3d scene that
other objects can cut through and interact with. In this one we're going to go to shading
and we're going to add a new material, principle bsdf. And just make it this metallic low roughness
kind of mirror surface. Ok perfect and then go back into rendered. Let's go to layout.
Ok go to camera view. And you see now we have this giant mirror in our scene and we can
rotate it. Woops, I am not rotating the right thing. Make sure that you have the right object
selected and we can rotate our giant mirror and do a lot of cool effects like this. Rotate
it on this axis like that. So I don't know you can do a whole bunch of stuff with this
but this is just a video about camera mapping so let's close this out. So this is again
a simple example because we just made a cube. In other cases we have stairs, we have trees
and a lot of that will require cylinders and a bunch of harder geometry. But this is the
most simple case, I think I'm also going to make a video about the harder case but either
way I hope you learned something. Thank you for watching, make sure to use subsurf after
you put uv project. Either way thanks for watching. Bye guys.