Tutorial Render with Blender

Introduction
This tutorial shows how to produce a rendered image in Blender, beginning from a part or assembly created with FreeCAD. It assumes that the user already created the part in FreeCAD, or has imported it into it. Then this part is exported to Blender for rendering.

It produces a rendering with Blender 2.80 with both the EEVEE and Cycles renderers. It shows various Python commands that can be used to perform actions quicker both in FreeCAD and Blender.

FreeCAD
1. Create an assembly using bodies from the Part or PartDesign Workbenches, or any other workbench that produces solid objects, for example, the Arch Workbench. Assign colors or materials to the individual bodies that make the assembly, approximately matching the color that you want in your render.



2. If your model is very detailed, make sure the of the body is set to a low value, between  and, or even smaller. The lower this value is, the more detailed the exported mesh will be, and thus the better the quality of the render will be.



3. Select the, then , or press +, and export it as.

Alternatively, the export can be done from the Python console. Define a list of objects to be exported and use the exporting function with a file name.

when exporting to OBJ, two files are created; the first one contains the mesh information itself, ; the second one contains the definition of the materials, which in most cases is just the color,.

if the resulting OBJ file appears to be empty, you may have to export the individual bodies. In this case, select each of the bodies under the part, and repeat the export.

Prepare the model
4. Open Blender. Change the panel into a  (+). This will help you to input commands and see the results. You may divide this panel, to keep the console on one side, and make the other division an panel; this will allow you to see the code of the actions as you click on the interface.

Make sure you are using the EEVEE renderer. In the panel go to, and for  select.

5. Import the model file from the menu,.

Alternatively, importing can be done from the.

6. Change the scale.

If the bodies appear to be very large you may have to change the units so the objects appear at the right scale.

In the panel go to, , and select the appropriate , , and.

For small parts, you may wish to keep the length to, and the scale to. For bigger parts, for example, the model of a building, you may have to set these values to and. Try other values of scale as required.

This can be set also from the.

changing the scale and units of the scene is only necessary if you wish to work with objects at their true dimensions. If you just want to render your scene quickly, you may omit any adjustment.

6.1. If you zoom out, and the view cuts the imported parts, you may have to adjust the view clip values.

Hit to show the auxiliary panel; go to the  section and set the  to a large value, for example,  or.

6.2. If you wish, also adjust the size of the grid; go to, then , and set the of the grid to.

7. Fix the rotation of the objects.

When imported, objects may appear rotated around one of the axes, for example, 90 degrees around the X axis. Hit to show the auxiliary panel; select an object, go to the  section and set the  to  in each field. Do this for every object.

This can be automated by a small script that just sets the rotation of each imported body to zero, with the exception of the objects inside the tuple. This can be useful if you are importing objects into an existing scene where other objects are already in their right positions.



Prepare the camera of the scene
8. Set the camera in the right position.

Adjust the viewport to look at the model in the desired orientation, then hit ++ (numerical pad), or use the menu.

8.1. If you don't see anything in the camera view, you may need to adjust the clipping. Selecting the camera in the, go to the panel, then , then , then set the  to a large value, for example,  or.

If you can see the object through the camera view, now you can quickly render the model by pressing, which will open the with the result. Press to exit, and return to the.



You can toggle between camera view and the 3D viewport by pressing in the numerical pad; pressing  will render the camera view in any moment.

8.2. If the camera looks very small in the 3D viewport, go to the panel, then, then , and set a larger value for the , for example,. Also activate the checkbox to see the clipping distance of the camera.

Prepare the lighting of the scene
9. Select the light in the, go to the panel, then , then press on , and set the  to.

This will turn the light into a Sun lamp. This type of lamp emits an infinite number of parallel light rays that all arrive to the scene with a fixed angle.

You may position the Sun lamp anywhere on the viewport above your model so that you define the direction of the rays of light. For a Sun lamp it doesn't matter how close or far you place the lamp, only the direction of the rays, which are defined by the rotation of the object.

Press again to see a preliminary render of the model.



Add floor and global lighting
8. Add a floor plane. Click + then, , and give it dimensions 10 times larger than your model. This will serve as a ground plane or table top on which the model is standing. Also move the plane a bit down ( is enough), so that it does not intersect the model.

9. Set the world illumination. In the panel go to, and set  to a light blue-gray value, and the  to.

10. Set reflections. The EEVEE renderer of Blender produces fast renders by deactivating particular effects. In order to obtain better images, some options need to be made active.

Go to the panel, then, and check. In the section, also check.

Set the materials of the objects
11. Turn the panel into a  panel (+).

11.1. Select the ground plane, go to the panel, then, and click on. In the a  node should appear. Give it a beige, turn the to , and the  to.



11.2. Select each of the parts of the model, and adjust the respective material node. For metallic parts, turn the property all the way to. Adjust the value of to be between  and. The closer to the  is, the more reflective (mirror-like) it will appear.

For non metals, like plastics, wood and textiles, set the property all the way to, and adjust the value of  to between  and.

In general, metals are naturally smooth and therefore their roughness is small, making them shiny (reflective). Other materials are microscopically rough, and therefore do not reflect as much light, making them more opaque.

Test different combinations of materials until they look acceptable. Press and then  (numeric pad) to enter  mode; in this mode, the EEVEE renderer shows in real time in the 3D viewport how the final image will look like. Use to open the pie menu and switch back to  mode, or go to  mode , a mode which adds different types of lighting to the scene to test the materials.

Press to render the view through the camera and check the quality of your image.

Rendering and saving
12. If your model looks reasonable well with the EEVEE renderer you can already save the image by going to or pressing + in the.



13. If you want to improve the quality of the image, try the Cycles renderer.

Go to the panel, then, and for  select. With the Cycles renderer, Blender will refine the image gradually until a number of iterations have passed. Every time the viewport changes the recalculation restarts.

Press to render the final view through the camera. Depending on your graphics card (GPU) the image should take several more seconds, or minutes, to render with Cycles than with EEVEE, but the quality of the image should be better.

14. When you are satisfied with the quality of the image, go to or press +.



Importing plugin
Creating the intermediate Wavefront mesh (.obj) and then importing it into Blender will work in most situations. However, there is also the option of importing the FreeCAD file (.FCStd) directly into Blender by means of a plugin.
 * io_import_fcstd.py, original version for Blender 2.79
 * FreeCAD .FCStd importer for Blender 2.80

This is a Blender plugin; for it to work, Blender needs to be able to import FreeCAD as a module from the.

This is only possible if both Blender and FreeCAD are compiled against the same (major and minor) version. For example, if Blender is compiled against Python 3.7, FreeCAD must be compiled against a Python 3.7 version as well. If FreeCAD is compiled against another version, for example, Python 2.7.15 or Python 3.6.7, the plugin will not work. The micro version number (third number) does not matter, that is, the plugin should work if one software is compiled against Python 3.7.5 and the other against Python 3.7.8.

In addition, the FreeCAD precompiled Python module, on Linux and  on Windows, should be in the Python path used by Blender to import modules. This path can be set up in different ways, depending on the operating system and Python distribution.

In Blender you can see all paths searched by inspecting the variable. The FreeCAD module should be found in any of those directories.


 * A copy or symbolic link inside one of those directories could be created pointing to the FreeCAD module.


 * Another possibility is adding the module directly into the path inside Blender.

Final notes
EEVEE is not a physically accurate renderer, however its main strength is that it is a real time renderer so it is able to produce quick images directly in the 3D viewport. In many cases, these images have enough quality for final production which means it's possible to obtain a good result in a very short time.

On the other hand, Cycles is a true raytracing renderer which means it is more accurate at calculating light paths in a scene in order to produce a photorealistic result. Cycles is still the recommended renderer when the best quality is desired.

In many cases, the scene prepared with EEVEE can be used immediately without change in Cycles in order to produce a better rendering. However, in cases were complex light interactions are desired (reflections, refractions, volumetric light, and caustics) EEVEE is limited, and requires some tricks and options to work around some of these limitations.

Obtaining good results is highly dependent on the rendering options, the materials, and the lighting. The material shader is a generic solution that works well for many cases, however, to produce trully photorealistic results, the use of texture maps and normal maps, along with careful lighting of the scene is still very important.