Tutorial Render with Blender/fr

Introduction
Ce tutoriel montre comment produire une image rendue dans Blender, à partir d'une pièce ou d'un assemblage créé avec FreeCAD. Il suppose que l'utilisateur a déjà créé la pièce dans FreeCAD, ou l'a importée dedans. Ensuite, cette partie est exportée vers Blender pour le rendu.

Il produit un rendu avec Blender 2.80 avec les moteurs de rendu EEVEE et Cycles. Il montre diverses commandes Python qui peuvent être utilisées pour effectuer des actions plus rapidement à la fois dans FreeCAD et Blender.

Une description similaire de ce processus est décrite dans une série de vidéos, Render Solidworks and FreeCAD Models in Blender par Joko Engineering.

FreeCAD
1. Créez un assemblage en utilisant des corps de l'atelier Part ou atelier PartDesign, ou de tout autre atelier produisant des objets solides, par exemple, l'atelier Arch. Attribuez des couleurs ou des matériaux aux corps individuels qui composent l'assemblage, en correspondant approximativement à la couleur souhaitée dans votre rendu.



2. Si votre modèle est très détaillé, assurez-vous que la valeur du corps est défini sur une valeur basse comprise entre  et  voire moins. Plus cette valeur est basse, plus le maillage exporté sera détaillé et donc meilleure sera la qualité du rendu.



3. Sélectionnez, puis , ou appuyez sur + , et exportez-le sous.

Alternativement, l'exportation peut être effectuée depuis la console Python. Définissez une liste d'objets à exporter et utilisez la fonction d'exportation avec un nom de fichier.

lors de l'exportation vers OBJ, deux fichiers sont créés; le premier contient les informations du maillage lui-même, ; le second contient la définition des matériaux, qui dans la plupart des cas est juste la couleur,.

si le fichier OBJ résultant semble vide, vous devrez peut-être exporter les corps individuels. Dans ce cas, sélectionnez chacun des corps sous la pièce et répétez l'exportation.

Préparez le modèle
4. Ouvrez Blender. Changez le panneau dans une  (+). Cela vous aidera à saisir des commandes et à voir les résultats. Vous pouvez diviser ce panneau, pour garder la console d'un côté, et faire de l'autre division un panneau ; cela vous permettra de voir le code des actions en cliquant sur l'interface.

Assurez-vous que vous utilisez le moteur de rendu EEVEE. Dans le panneau, allez dans , et pour sélectionnez.

5. Importez le fichier de modèle à partir du menu,.

Alternativement, l'importation peut être effectuée à partir de la.

6. Modifiez l'échelle.

Si les corps semblent très grands, vous devrez peut-être changer les unités pour que les objets apparaissent à la bonne échelle.

Dans le panneau, allez dans , , et sélectionnez le , , et.

Pour les petites pièces, vous pouvez conserver la longueur à et l'échelle à. Pour les pièces plus volumineuses, par exemple le modèle d'un bâtiment, vous devrez peut-être définir ces valeurs sur et. Essayez d'autres valeurs d'échelle si nécessaire.

Cela peut également être défini depuis la.

changer l'échelle et les unités de la scène n'est nécessaire que si vous souhaitez travailler avec des objets à leurs dimensions réelles. Si vous souhaitez simplement rendre votre scène rapidement, vous pouvez omettre tout ajustement.

6.1. Si vous effectuez un zoom arrière et que la vue coupe les pièces importées, vous devrez peut-être ajuster les valeurs des vignettes de la vue.

Appuyez sur pour afficher le panneau auxiliaire; Accédez à la section  et définissez  sur une valeur élevée, par exemple  ou.

6.2. Si vous le souhaitez, ajustez également la taille de la grille; allez à, puis , et définissez de la grille sur.

7. Réglez la rotation des objets.

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.



More setup: floor, global lighting, reflections, and soft shadows
10. Add a floor plane. Press + then choose, , and give it dimensions about 10 times larger than your model. This mesh object will serve as a floor plane or table top on which the model is standing. Also move the plane a bit down so that it does not intersect the model; below the object is enough.

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

12. Set reflections and shadows. The EEVEE renderer of Blender produces fast renders by deactivating most effects initially. 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
13. Turn the panel into a  panel (+).

13.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  slider to , and the  to.



13.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 slider all the way to, and adjust the value of  to between  and.

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

14. Test different combinations of materials until they look acceptable. Press and then  (numerical 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 appearance of the materials.

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

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



16. 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.

16.1. Adjust the sampling rate. Go to the panel, then, then in the  section select an appropriate number for  and.

For the a small number of samples, in the range of  to, is generally enough to obtain a good preview of the image. For the final image, set to a higher number, from  to, depending on the complexity and amount of details on the scene.

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.

17. When you are satisfied with the quality of the rendering, in the go to  or press +.



Rendering from the command line
18. If the scene has been completely finished, you may wish to render from outside Blender, from the operating system's command line. This can be useful to batch render different scenes in a remote system. Both EEVEE and Cycles are supported.

This specifies that rendering should happen in the background with ; the rendering engine is chosen with ; the output filename is selected with ; the double forward slash indicates a path relative to the input file; the hash mark  is used to indicate the frame number, padded with zeroes if necessary, for example, ; the number of CPU threads used in rendering is chosen with ; the output file format is indicated with, and the  option adds automatically the extension to the name; the final option is  which indicates that only the first frame will be rendered, which is the normal case for a static scene; for animations use the  switch to produce an image for each frame, which can then be assembled to produce a video file.

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 engine so it is able to produce quick renderings directly in the 3D viewport. In many cases these images have enough quality for final production, which means it is possible to obtain a good result in a very short time. In cases where complex light interactions are desired (reflections, refractions, volumetric light, and caustics) EEVEE is more limited, and requires some options and tricks to work around some of these limitations.

On the other hand, Cycles is a true raytracing renderer which means it is more accurate at calculating light paths in a scene. Cycles is the recommended renderer when the best quality is desired (photorealistic results), at the cost of more rendering time.

Both renderers can be used to leverage the advantages of each. In many cases the scene can be quickly prepared and tested with EEVEE to obtain preliminary renderings; then the same scene can be used with minor changes with Cycles in order to produce a higher quality, final rendering. In particular, when a scene that was setup with EEVEE will be used with Cycles, the lights may need to be adjusted in value and position as both renderers treat light in different ways.

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 truly photorealistic results, the use of texture maps and normal maps, along with careful lighting of the scene is still very important.