Add 3D Models to Images in Blender - Learn to Render Realistic Images | Mika Jäntti | Skillshare

Playback Speed


  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x

Add 3D Models to Images in Blender - Learn to Render Realistic Images

teacher avatar Mika Jäntti, Game Development | Coding | 3D Graphics

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Lessons in This Class

9 Lessons (43m)
    • 1. Learn to Add a 3D Model to an Image!

      1:12
    • 2. Downloading and Installing fSpy

      2:27
    • 3. Exercise 1: Camera Perspective

      3:50
    • 4. Exercise 1: 3D Model to Image

      5:16
    • 5. Exercise 1: Light and Shadows

      5:29
    • 6. Exercise 2: Camera Perspective

      1:51
    • 7. Exercise 2: 3D Models to Image

      2:58
    • 8. Exercise 2: Shadows and Reflections

      19:50
    • 9. The End

      0:11
  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels

Community Generated

The level is determined by a majority opinion of students who have reviewed this class. The teacher's recommendation is shown until at least 5 student responses are collected.

12

Students

--

Projects

About This Class

Learn to add a 3D model to an image! The first step is to get the perspective of the camera in Blender to match the perspective of the actual camera on which the photo was taken. After that, the 3D model and a plane object will be added to the 3D space. The next step is to make the 3D model form a shadow and, if necessary, a reflection on the surface of the plane object so that they appear to be on top of a surface that is in the image. This makes the end result as realistic as possible. Lastly, an image of the view is rendered.

Skills you will learn:

  • using fSpy to define the right perspective for the camera

  • forming a shadow on a surface in an image

  • forming a reflection on a surface in an image

  • using the node editor in the Compositor window

  • using rendering layers and collections

  • rendering the view into an image

This course is meant for 3D artists who already have some experience with Blender, but if you are a motivated beginner, this course is great for you as well. The programs used in the course, ie Blender and fSpy, are free.

The course includes two exercises that will get you familiar with the process. In the first exercise, a 3D model of a clock will be added to a wall in an image so that the clock forms a shadow on its surface. In the second exercise, 3D models of three coffee mugs will be added on top of a glass table in an image so that they will form both a shadow and a reflection on it. To do this they must be rendered in separate rendering layers and after that those layers will be added on top of each other using the node editor in the Compositor window.

After the course, you can use the skill you have learned to add any 3D models on the surfaces of different kinds of images. This skill is often used, for example, when you want to fill an image of an empty apartment with realistic 3D models of furniture.

Meet Your Teacher

Teacher Profile Image

Mika Jäntti

Game Development | Coding | 3D Graphics

Teacher

I teach skills such as Game Development, Coding, and 3D Graphics. My goal is to create high-quality content where I always get straight to the point. In addition to online courses, I develop and publish PC games on Steam. Make sure to follow me here so you'll know when I publish a new course. Thanks!

See full profile

Class Ratings

Expectations Met?
    Exceeded!
  • 0%
  • Yes
  • 0%
  • Somewhat
  • 0%
  • Not really
  • 0%
Reviews Archive

In October 2018, we updated our review system to improve the way we collect feedback. Below are the reviews written before that update.

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

Take classes on the go with the Skillshare app. Stream or download to watch on the plane, the subway, or wherever you learn best.

Transcripts

1. Learn to Add a 3D Model to an Image!: In this course, you will learn how to add a 3D model to an image in Blender. This process consists of the following steps. Defining the perspective of the camera with a program called Fs by adding the 3D model on top of an image and forming a shadow and a reflection on the surface in the image. The last step is to render the view. In the first exercise, this 3D model of a clock will be added to this image so that it casts a shadow on the wall. In the second exercise, these three coffee mugs will be added to this image. And after that, they will be adjusted to form both a shadow and a reflection on the surface of the table. This course is meant for 3D artists will already have some experience with Blender. But if you are a motivated beginner, this course is great for you as well. The programs used in the course are free. Enroll in the course and learn one of the most essential skills of a 3D artist. 2. Downloading and Installing fSpy: Let's start off by downloading apps by type the name of the program in the search field. There are formed deserts. And click the first search result. Scroll down a bit and click the download button with the middle mouse button so that the base openness in a new tab. After that, go to that tab, download the version corresponding to the operating system of your computer. Run the downloaded is taller. The program will open when the installation is complete. The next program to download is an add-on that lets you import Fs by files into planter. Opened the first step of the browser with just the front page of apps by Gleick, the official apps by importer add-on link. Scroll down a bit and click the download the latest version link. Select the apps by blender option to download the add-on. Open the downloaded file and extract it temporarily on your desktop. For example. Next, open the file location of Blender add-ons for Windows, the default bath East, this drag the Fs by add-on from the desktop to the ADOS folder. Click the Continue button. The last thing you need to do is to enable the add-on in Blender. So open Blender, go to Edit Preferences. Make sure you are on the add-ons tab. Type in the search field, and click the checkbox next to the name of the add-on to activate it, close the window. Everything is now set up for the first exercise. 3. Exercise 1: Camera Perspective: In the first exercise, these 3D model of a colic will be added to this photo. These two files can be found in the resources of this course with the names block dots blend and project one dot JPEG. Download them. The first step is to get the perspective of the camera in Blender to match the perspective of the actual camera on which the photo was taken. This is effortless with the help of Fs by drag the download at Project one photo laughs by. You get the right perspective. The red and green lines must be aligned with the elements of the photo success, the corners of the walls, the program has darkened the photo. So a maths that the corners of the walls cannot be easily distinguished. You can turn off the darkening of the photo by deactivating the DMM emits sitting on the left side of the user interface. I didn't remember to deactivate these setting myself while recording this lecture. So try your best to see where the lines are moved in this video. Let's start by moving the two points of the first thread line along the top of the tiles at the bottom of the photo. Move the first to the corner of the walls. The second should be moved to the point where the tiles disappear from the photo. Next, more than two points of the green line with the opposite side of the red line along the top of the tiles. Move the first on top off the red point in the corner of the walls. Move the second to where the tiles disappear from the photo. The light that Arthur two lines along the edge of the ceiling move their points of the red line with the same wall, where the previous red line is. Then move the green line to the opposite wall so that it goes along the edge of the ceiling. Now that the lines are set, the C axis of the coordinate system in the center of the photo should point upwards. If it points downwards, Jane stacks and y-values of the vanishing point axes setting on the left side of the user interface, the value of the first drop-down menu should be y. And the second one. You can make sure that their perspective is set correctly by opening the 3D guide drop-down menu and selecting the box option. When you move the coordinate system from its center over the window in the photo, the edges of the cube around the coordinate system should match the edges of the window. If needed, you can modify the perspective by moving the points of the red and green lines. The center of the 3D space in the blender file will be the center of this coordinate system. Move it to the intersection of the two lines at the bottom of the photo, for example, their perspective has now been defined. So saved the apps by file. Go to File. Save As name the file, for example, project one. And click the Save button. Close F spy. 4. Exercise 1: 3D Model to Image: Let's continue the first exercise. The next step is to import the apps by file to Blender and add the 3D model of the clock to the photo open blender. Before importing the apps by file in the planter, delete all objects in the 3D space by first selecting them with a, then pressing X and the left mouse button. Go to File. Import Fs by select the Project one dot f's by file, and click the Import button. The add-on automatically added a camera that a 3D space which has the perspective you defined in Fs by the camera, has a background image, that is the photo you used in apps. By by default, the background image is slightly transparent. Working with it would be easier if you couldn't see through it. So I'll go to the Object Data Properties tab to change the transparency of the image open in the background images section, and change the opacity setting of the background image to one. Next, let's add the 3D model of the clock to the photo. Open the blend file you downloaded earlier. Use a, select all parts of the clock and press control C to copy them. Now, open the previous blend file and press Control V to paste the clock into the 3D space. Move the clock next to the window by first pressing G, C, then g, x. As you can see, the clock moves on the surface of the wall, which means the perspective of the camera has been set correctly. If this view is interred at these points, the result loose like this. There is a gray background behind the clock, and the clock itself is dark because there is no light source in the 3D space. On top of all this, the photo was not rendered because it is just a background image of the camera. Let's fix all these issues by first activating a setting that makes the background of the 3D model transparent because the purpose is to render only the clock and add it to the photo. Go to the render properties tab. Expand the field section and activate the transparent setting. Next, let's modify the composition settings so that the photo will be added to the background of the clock. After the rendering is complete, go to the compositing workspace. Activate the US node setting in the top bar of the composite or window so that the composition settings will be displayed as a node system. Move the composite node further away from the render layers node to make some room between them. Next, add the photo as a note by adding a new node, which shift click asserts and search for a node called imaged. Then select it. Click the Open pattern of the node. Select the Project one image, and click the Open pattern to add the photo as the background of the 3D model, you will need to add a node called mix, press, Shift, a Gleick asserts and type mix in the search field, select the mix option. Drag a line from the emits outputs of the image snowed. The RPA or emits input of the mixed node. Next, drag a line from the image output of the render layers node. The lower image, the impulse of the mixed node, the order of the connection matters so that the photo is inserted behind the 3D model and not in front of it. Now, drag a line from the alpha output of the render layers node. Fact, in both of the mixed node so that the node system takes into account the transparency of the rendered image. Finally, drag a line from the output of the mixed node that the image, the input of the composite node, the node system is now complete. Press F2 to render the image. This is how you can add a 3D model through a photo, allows the render window use Control S to save the project. Name, the project, project one, and click the Save button. 5. Exercise 1: Light and Shadows: Next, let's add a light source to the 3D space and set the clock, the forearm, a shadow that appears to be on the surface of the wall in the photo, the cycles engine will be used to render the final emits. So at this point, make sure you have selected the cycles option from the render engine drop-down menu. Go to the default workspace. Press Shift, and select light area. Move the light source initially to the same location as the clock. Breaths G. Then G, x. Now press G to move it away from the clock. After that, move it upwards so that it is approximately at the same location as the lamp in the room from which the photo was taken. Breaths G, C. Lastly, rotate the light source, the point toward the clock. Breaths are x. Whereas see and change the drawing mode, the rendered. As you can see, the clock doesn't form any kind of shadow because there is no actual geometry behind it in which the shadow could be formed. In order the forum or shadow, a blend object must be added behind the clock, which will be used as a shadow catcher. The geometry of an object marked as a shadow catcher will not be rendered at the shadows on its surface. Cost by other objects will be rendered. Whereas C and Jains the drawing mode back to solid, press, Shift and select mesh. Blaine rotated 90 degrees on the x-axis by first pressing R x, then dy being 90, and clicking the left mouse button, move the blame object to the same location as the clock by pressing G, C. Then G x. The plane object is too small at the moment, so scale it up with, Let's now mark the plane object as a shadow catcher. Breast see and change the drawing mode to rendered so you are able to see how a shadow catcher works. Go to the Object Properties tab. Expand the visibility section, activate the shadow catcher setting. The geometry of the plane object is no longer rendered, but it still catches the shadow cost by the clock, so to speak. In the sea the shadow better. You should deactivate the diffuse and clauses settings in the visibility section so that the plane object doesn't affect the appearance of other objects in any way. The next step is to adjust the lighting settings. So select the light source. The goal is to illuminate the clock so that it is as bright as the other elements either photo. In addition to this, it is important to make the shadow of the clock look the same as the shadows in the photo. In this case, it is a good idea to use the shadow next to the window as an example. As you can see, the shadow is needed. There are very dark nor sharp. The change the lighting settings go to the Object Data Properties tab. By adjusting the values of the power and size settings, you can change the price newness of the clock, and the shadow it forms. You may want to adjust the settings until you find the values that yield the best results. In this case, the value of the power setting should be around 50 watts and the value of the size setting around five meters or 15 feet. The light source is now five meters wide, which is not correct at all as the actual lamp is only about half a meter wide. However, this doesn't matter because it is more important to get the clock to be apart of the photo as well as possible. If you think the lighting should be improved, you can change the rotation and location of the light source in addition to the power and size values, press F12, the render an image of the view. The first exercise is now complete. To save the image, click Image, Save As name the image. For example, project one, and click the Save button. 6. Exercise 2: Camera Perspective: In the second exercise, these 3D models of colorful coffee marks will be added to this photo. The files can be found in the resources of the course with the names, coffee marks, dots blend and project two dot JPEG. Download them. Let's start by defining the perspective of the camera. So open Fs by, drag the project to image two apps by move the red and green lines to the edges of the table. More. The first red line to the nearest edge of the table. The second red line to the rear edge of it. Now move the green lines to the left and right sides of the table. The last step is to move the coordinate system, for example, to the lower-left corner that the intersection of the red and green lines. Everything is all set now. So save the Fs by file, go to File, Save As name the file for example, project to click the save button, glows Fs by. 7. Exercise 2: 3D Models to Image: Let's take the F spy file to Blender and add the coffee marks on top of it. Opened Blender. Go to File. Import Fs by is select the project to that Fs by file and click the Import button. Change the transparency of the cameras background image. So I'll go to the Object Data Properties tab, expand the background images section and change the opacity setting off the background image, the one bringing the coffee marks that this blender file open the coffee marks that blend file you downloaded earlier. Select them all with a and copy them with Control C. Open the previous blender file and paste them to the 3D space with Control V. Move the marks, the different points on the table. Select a mug, breaths G, then Shift C. This is how you can move an object only on the x and y-axis. Press G first, then Shift C. You can also rotate them randomly with our sea. If you think the marks are too small, you can enlarge them. First, select them while holding down Shift, open the transform people to point drop-down menu from the top bar of the 3D viewport window and select the individual origins option. When you scale the marks larger with S scale according to their individual pivot points, change the value of the transform people with born to drop down menu back to the default one, which is the median point. At this point, let's make a couple of changes to the rendering settings. So go to the render properties tab, open the render engine dropdown menu and select the cycles option. Now expand the film section and activate the transparent setting so that the background will be rendered transparent. Save the project with Control S. Name it for example, project to click the Save button. 8. Exercise 2: Shadows and Reflections: This exercise differs from the previous one in that the 3D model should form a reflection on the surface of the plane object in addition to the shadow. This makes this exercise more challenging. First, add a plane object. So press Shift, Select Mesh, Blaine, move it to the center of the tape or by pressing G and then Shift C. Press S and scale it to be so big that it completely covers the view of the camera. It makes sure that the blame object goes over the top of the camera view. Otherwise, there will be problems during the rendering phase. C and change the drawing mode, the rendered, so you are able to see how they following changes will affect the view. Let's add a light source to the 3D space. Press Shift and select light sun. This option is best for this case, even though it doesn't match the lamp of the room from widths their photo was taken. The location of the sun light source doesn't matter. So leave it at the 0 of the 3D space. Now select the plane object. Both of the material properties tab, add a new material by clicking the New button. First, change the value of the metallic, setting the 0.5. Next, James, the value of the roughness sitting to 0. Now you should be able to see the reflections of the coffee marks on the plane object surface. The coffee marks blast the shadows and reflections on the surface of the plane object will be rendered in separate rendering layers, after which they will be bought on top of each other using the node system in the composite or a window. Before adding new rendering layers, Let's create a new collection in the outliner window. Click the right mouse button over the window and select a new collection option, renamed the collection by double-clicking on its name, name it coffee marks. Now renamed the original collection by dark black legging its name, rename it getchar. Select the three marks in the outliner window by holding down Control. Move them inside the coffee marks collection. Now select the camera and the light source while holding down control. Drag them outside of both collections. You should now have a collection named cancer that has a plane object inside it, which will be used to render the shadows and the reflections. In addition that this user to have a collection named coffee mugs with the coffee marks inside the camera and the light source should be outside the collections. Just for the sake of clarity, link the Filter button in the upper-right corner of the outliner window. Activate the indirect only setting. The indirect only setting can now be seen next to the collections. When these setting is activated, the objects in that collection will only be rendered indirectly. That is, only their shadows and reflections will be rendered. Next, let's add the necessary rendering layers. By default, the project has one rendering layer called View layer. To create a new layer, click the button next to the view layer a text, then select the new option. Click on the name field and name the new layer cancer. Create another layer by clicking the pattern next to the field and selecting the new option. Click on the name field and name this one, coffee marks. In the coffee marks layer only the marks should be rendered. So activate the indirect only setting next to the capture collection. Use it now see only the coffee marks in the 3D space without any shadows or reflections. Now select the catcher rendering layer. Only shadows and reflections should be rendered in this layer. So activate the indirect only sitting next to their coffee market's collection. Only the shadows and reflections along with the plane object should now be visible in the 3D space. The plane object will be deleted later when adjusting the compositing settings. A couple of changes should be made that these cancer rendering layer go to the view layer properties tab, activate the denoising data setting. Then go down a bit and activate the indirect setting off the item. Next, activate the shadow setting off the other item. Make sure that you're rendering layers and collections look the same as in the video. This is what your coffee marks layer should look like. Your catcher layer should look like this. Next, go to the compositing workspace to modify the compositing settings. Activate the US nodes sailing in the top bar of the composite or window. Move the composite node away from the render layers node, breast in the hide the side panel. First, let's add the photo to the background of the 3D models, just like in the previous exercise. Press Shift a to add a new node. Gleick certs type image and select it. Click the notes open pattern, and select the project to image file. Next, both the coffee marks render on top of the background image. This time, instead of using the mixed node, use a node, It's called Alpha over because it is easier to work with it. In this case, press Shift and click Search, type alpha over and select it. Drag a line from the image output of the image node to the upper image input of the Alpha over a node. Now drag the image output of the render layers node to the output of the lower emits in both of the Alpha over a node. Finally drag the image output of the Alpha over. And note that the image, the input of the composite node, various F12 to render an image. Because there are three rendering layers, they will all be rendered sequentially. Lost the render window. Let's open the UV editor window in the window below the composite or window, so you are able to see the render results. At the same time, you modify the compositing settings. Click the button in the upper left corner of that window. Select UV editor. Open the texture list to the left of the New button, and select the render resolve option. You can move in the UV editor window by holding down the middle mouse button while moving your mouse. Scroll the mouse wheel to zoom in and out. They rendered emits is otherwise good, but the plane object in it covers the background image is completely disease because the default rendering layer, view layer is selected in the render layers node and the indirect only setting in the cat circle action is not activated in that particular rendering layer. Open the drop-down menu and select the coffee marks layer. As you probably noticed, changes made in the composite or window are immediately updated in the rendered image. The coffee marks are on top of the class table, but there are no shadows or reflections under them. Let's add them next. Let's make the note system have two nodes with which the density of the shadows and reflections on the surface of the plane can be freely adjusted. Start by adding another render layers snowed, in which the catcher rendering layer will be selected from its dropdown menu. The move around the composite or window, hold down the middle mouse button. While moving your mouse. Select the existing render layers node and duplicate it with Shift D. Open the drop-down menu at the bottom of it and select the catcher option. These rendering layer contains more settings speakers you previously activated them on the view layer properties tab. First make the coffee marks forum a shadow. The shadows have been rendered in the catcher rendering layer. So let's work with the lower render layers node. Let's take a step by step look at what the node system looks like. So move the composite node down so you can see it. Drag the shadow out both of the render layers node. The image in both of the composite node. The shadow information for that layer looks like this. By default. You shift a to add a new node. Leak asserts, dive, invert, and select it. Moving over the line that comes from the render layers node, so that the new node connects to the node system. As the name implies, the invert node reverses the colors. Let's change the black color in the image to transparent in a while so that there will only be the shadows of the marks visible. At this point. It should be mentioned that if you have a different version of Blender than in the video, some nodes may look different. This may affect how they work. So you may not get the same result with the same node system S in the video. If you encounter such a problem, send a message the whole lot. Now, we can find a solution to the problem. Let's add a node that can be used to adjust the strength of the shadows. Later, find a node called Math and more width to the right of the invert node. Open the drop-down menu in the math node and select the multiply option. Leave the value of the node's value, setting the 0.5. For now, the white areas in the image are now slightly darker. Add a node called set alpha to the right of the math node. The value output of the math node, whilst at that to the image output of the set alpha node by default, moving to the Alpha in both. If you see a drop-down menu in the set Alpha note, make sure you have selected they replace alpha option. They said Alpha node changes the color of the image, in this case black, the transparent. Only the shadows of the coffee marks can now be seen. Ed meets. So let's add them behind their marks. Disconnect the image node from the Alpha over a node temporarily, and more of it elsewhere. Drag the image output of the set for node through the upper image input of the Alpha over a node. Now drag the meats output of the Alpha over a note to the image input of the composite node. Now there are coffee marks and their shadows in the image. Next, at the photo to the background, select the Alpha over node and press Shift D to duplicate it. Move it to the right of the original Alpha over a node. Now track the image output of the image node through the upper image input of the new alpha over a node. The last thing to do is to add their reflections to the image. In addition to the shadows, the reflections are also rendered in the catcher rendering layer selected in the lower render layers node. Drag the gloss int, input of that node. The image, the input of the composite node to see what the reflection information looks like. By default. If necessary, you can arrange the node spatter, add a new math node. More with over the line that comes from the gloss paint in both of the render layers, node, open the math nodes dropdown menu and select the sign option. This option changes to call our information to black and whites. After a while, the black color of the image is changed the transparent, so that there will only be reflections in the image. Next, add a node that you can use to adjust the strength of the reflections at a math node and more of it to the right of the previous math node. Open its dropdown menu and select the multiply option. James devalue of its values setting the 0.2. Now remove the black area from the image by adding a node called set Alpha. Moving to the right of the second math node, drag the value output of the second math node that the alpha input of the set of a node. If you see a drop-down menu in the set alpha node, makes sure you have selected the replace alpha option. Only the reflections of the marks can now be seen in the image. However, they are currently black and white because the midst value of the set alpha node is black. Combined their original color information with the black and white reflections by dragging the gloss into output of the render layers node D meets the input of the set alpha node. Now let's combine the reflections with the other nodes. Select an existing Alpha over node and press Shift D to duplicate it. Disconnect the midst node from the Alpha over a node in the middle and move the image snowed elsewhere. Drag the image output of the lower set Alpha. Note that the upper image, the input of the Alpha over a node in the middle, now track the image output of the Alpha over a note in the middle of the lower image input of the newest Alpha over anode, reconnect the image node to denote system by dragging its image output with the upper image, the input of the newest Alpha over a note. Finally drag the image output of the Alpha over and note that the image, the input of the composite node, the image is now complete. When you look at the reflections closer, you will notice a black outline around them. You can remove them by blurring the reflections. Add a new node called Blur. Move it to the right of the lower set Alpha Node JS to x and y-values in it to be, for example, three. Node system is now complete. Did change the strength of the shadows, adjust the value of the values setting in this math node. If you wanted to change the strength of the reflections, James, the corresponding value of this math node. The further enhance the image. Go to the world Properties tab. Expand the ambient occlusion section and then activate it. Changed the value of both factor and distance settings, the 0.1. These changes will lighten the coffee marks a little bit. Press F12 to render the view. To save the image, click Image, Save As, name it. For example, click the Save button. 9. The End: Congratulations on completing the course. I hope you learned a lot. Please rate this course as it will help us a lot. Thank you.