Raytracing Workbench/fr: Difference between revisions

From FreeCAD Documentation
(Updating to match new version of source page)
No edit summary
 
(179 intermediate revisions by 15 users not shown)
Line 1: Line 1:
<languages/>
The Raytracing module is used to generate photorealistic images of your models, by rendering them with an external renderer. The Raytracing workbench works with [[Raytracing Module#Templates|templates]], the same way as the [[Drawing Module|Drawing workbench]], by allowing you to create a Raytracing project, in which you add views of your objects. The project can then be exported to a ready-to-render file, or be rendered directly.

{{Docnav
|
|
|IconL=
|IconR=
}}

{{VeryImportantMessage|L''''atelier Raytracing''' n'est plus inclus depuis la version 0.20.<br>
L'atelier externe [https://github.com/FreeCAD/FreeCAD-render Render] peut être utilisé à la place.}}

[[Image:Workbench_Raytracing.svg|thumb|128px|Icône de l'atelier Raytracing]]

== Introduction ==

{{TOCright}}

L'[[Image:Workbench_Raytracing.svg|24px]] [[Raytracing_Workbench/fr|atelier Raytracing]] est utilisé pour générer des images photoréalistes de vos modèles en les interprétant avec un moteur de rendu externe.

L'atelier Raytracing fonctionne avec des [[Raytracing_templates/fr|modèles]], qui sont des fichiers de projet définissant une scène pour votre modèle 3D. Vous pouvez placer des lumières et des géométries telles que des plans de sol. Il contient également des espaces réservés pour la position de la caméra et pour les informations sur les matériaux des objets de la scène. Le projet peut ensuite être exporté dans un fichier prêt à être restitué, ou directement dans FreeCAD.

Actuellement, deux moteurs de rendu sont pris en charge : [[POV-Ray/fr|POV-Ray]] et [[LuxRender/fr|LuxRender]]. Pour être en mesure d'effectuer un rendu à partir de FreeCAD, au moins un de ces programmes doit être installé et configuré dans votre système. Cependant, si aucun programme de rendu n'est installé, vous pourrez toujours exporter un fichier de projet pour le rendre à un autre moment.

L'atelier Raytracing est obsolète, l'atelier externe [https://github.com/FreeCAD/FreeCAD-render Render] le remplace. Néanmoins, les informations contenues dans cette page sont généralement utiles pour le nouvel atelier car les deux fonctionnent basiquement de la même manière.


[[Image:Raytracing_example.jpg|1024px]]
[[Image:Raytracing_example.jpg|1024px]]


== Déroulement typique du travail ==
Currenly, two renderers are supported: [http://en.wikipedia.org/wiki/POV-Ray povray] and [http://en.wikipedia.org/wiki/LuxRender luxrender]. To be able to render directly from FreeCAD, at least one of those renderers must be installed on your system, and its path configured in the FreeCAD Raytracing preferences. Without any renderer installed, yhough, you are still able to export a scene file that can be used in any of those renderers later, or on another machine.
# Créez ou ouvrez un projet dans FreeCAD, ajouter quelques objets solides [[Part_Workbench/fr|Part]] ou [[PartDesign_Workbench/fr|PartDesign]]; le maillage n'est actuellement pas pris en charge.
# Créez un projet de Raytracing (povray ou luxrender)
# Sélectionnez les objets que vous souhaitez ajouter au projet Raytracing et ajoutez-les au projet avec l'outil "Insert Part"
# Exportez le fichier projet ou créer le rendu directement


The raytracing workbench works with [[Raytracing Module#Templates|templates]], which are complete scene files for the given external renderer, including lights and possibly additional geometry such as ground planes. These scene files contain placeholders, where FreeCAD will insert the position of the camera, and geometry and materials information of each of the objects you insert in the project. That modified scene file is what is then exported to the external renderer.


[[Image:Raytracing_Workbench_workflow.svg|600px]]
== Tools ==


{{Raytracing Tools}}


{{Caption|Le flux de travail de l'atelier Raytracing; l'atelier prépare un fichier de projet à partir d'un modèle donné, puis appelle un programme externe pour produire le rendu réel de la scène. Le rendu externe peut être utilisé indépendamment de FreeCAD.}}
== Typical workflow ==
# Create or open a FreeCAD project, add some [[Part Module|Part-based]] objects (meshes are currently not supported)
# Create a Raytracing project (luxrender or povray)
# Select the objects you wish to add to the raytracing project and add them to the project with the "Insert Part" tool
# Export or render directly


<span id="Tools"></span>
== Creating a povray file manually ==
== Outils ==
The utility tools described above allow you to export the current 3D view and all of its content to a [http://www.povray.org/ Povray] file. First, you must load or create your CAD data and position the 3D View orientation as you wish. Then choose "Utilities->Export View..." from the raytracing menu.


<span id="Project_tools"></span>
[[Image:FreeCAD_Raytracing.jpg|center]]
===Outils de projet===


Ce sont les principaux outils d’exportation de votre travail 3D vers des rendus externes.
You get ask for a location to save the resulting *.pov file. After that you can open it in [http://www.povray.org/ Povray] and render:
* [[Image:Raytracing_New.svg|32px]] [[Raytracing_New/fr|Nouveau projet PovRay]]: Insérer un nouveau projet PovRay dans le document
* [[Image:Raytracing_Lux.svg|32px]] [[Raytracing_Lux/fr|Nouveau projet LuxRender]]: Insérer un nouveau projet LuxRender dans le document
* [[Image:Raytracing_InsertPart.svg|32px]] [[Raytracing_InsertPart/fr|Insérer une pièce]]: Insérer une vue d'une pièce dans un projet de lancer de rayons
* [[Image:Raytracing_ResetCamera.svg|32px]] [[Raytracing_ResetCamera/fr|Réinitialiser la caméra]]: Fait correspondre la position de la caméra d'un projet de lancer de rayons à la vue actuelle
* [[Image:Raytracing_ExportProject.svg|32px]] [[Raytracing_ExportProject/fr|Exporter un projet]]: Exporte un projet de lancer de rayons dans un fichier de scène pour le rendu dans un rendu externe
* [[Image:Raytracing_Render.svg|32px]] [[Raytracing_Render/fr|Rendu]]: Rend un projet de lancer de rayons avec un moteur de rendu externe


<span id="Utilities"></span>
[[Image:Povray.jpg|center]]
===Utilitaires===


Ce sont des outils auxiliaires pour effectuer manuellement des tâches spécifiques.
As usual in a rendererer you can make big and nice pictures:
* [[Image:Raytracing_WriteView.svg|32px]] [[Raytracing_WriteView/fr|Exporter la vue vers Pov-Ray]]: Exporte la vue 3D active avec la caméra et tout son contenu dans un fichier povray.
* [[Image:Raytracing_WriteCamera.svg|32px]] [[Raytracing_WriteCamera/fr|Exporter la caméra vers Pov-Ray]]: Exporte la position de la caméra de la vue 3D active au format POV-Ray dans un fichier.
* [[Image:Raytracing_WritePart.svg|32px]] [[Raytracing_WritePart/fr|Export de la pièce vers Pov-Ray]]: Exporte la partie sélectionnée (objet) en tant que fichier povray.


<span id="Preferences"></span>
[[Image:Scharniergreifer_render.jpg|1024px]]
== Préférences ==


* [[Image:Preferences-raytracing.svg|32px]] [[Raytracing_Preferences/fr|Préférences]]: Préférences disponibles pour les outils Raytracing.
== Scripting ==


== Tutorials ==
=== Outputting render files ===
* [[Raytracing_tutorial/fr|Tutoriel basique Raytracing]]
The Raytracing and RaytracingGui modules provide several methods to write scene contents as povray or luxrender data. The most useful are Raytracing.getPartAsPovray() and Raytracing.getPartAsLux() to render a FreeCAD Part object into a povray or luxrender definition, and RaytracingGui.povViewCamera() and RaytracinGui.luxViewCamera() to get the current point of view of the FreeCAD 3D window into povray or luxrender format.
* [[Tutorial FreeCAD POV ray/fr|Tutoriel intermédiaire Raytracing]]


== Création manuelle d'un fichier povray ==
Here is how to write a povray file from python, assuming your document contains a "Box" object:
Les outils utilitaires décrits ci-dessus vous permettent d'exporter l'affichage 3D actuel et tout son contenu dans un fichier [http://www.povray.org/ Povray]. Tout d'abord, vous devez charger ou créer vos données CAO et positionner l'orientation de la vue 3D que vous le souhaitez. Puis choisissez "Utilitaires → Exporter la vue..." dans le menu de raytracing.
<syntaxhighlight>

import Raytracing,RaytracingGui
[[Image:FreeCAD_Raytracing.jpg|center]]
OutFile = open('C:/Documents and Settings/jriegel/Desktop/test.pov','w')

OutFile.write(open(App.getResourceDir()+'Mod/Raytracing/Templates/ProjectStd.pov').read())
Donnez un emplacement pour enregistrer le fichier *.pov. Après cela vous pouvez l'ouvrir dans [http://www.povray.org/ Povray] et obtenir le rendu :
OutFile.write(RaytracingGui.povViewCamera())
[[Image:Povray.jpg|center]]
OutFile.write(Raytracing.getPartAsPovray('Box',App.activeDocument().Box.Shape,0.800000,0.800000,0.800000))

OutFile.close()
Comme d'habitude dans un rendu vous pouvez faire de grandes et belles photos :
del OutFile
[[Image:Scharniergreifer_render.jpg|center|800px]]
</syntaxhighlight>

And the same for luxrender:
<span id="Scripting"></span>
<syntaxhighlight>
== Script==
import Raytracing,RaytracingGui

OutFile = open('C:/Documents and Settings/jriegel/Desktop/test.lxs','w')
Voir [[Raytracing API example/fr|Raytracing API exemples]] pour plus d'informations sur l'écriture de scènes par programmation.
OutFile.write(open(App.getResourceDir()+'Mod/Raytracing/Templates/LuxClassic.lxs').read())

OutFile.write(RaytracingGui.luxViewCamera())
<span id="Links"></span>
OutFile.write(Raytracing.getPartAsLux('Box',App.activeDocument().Box.Shape,0.800000,0.800000,0.800000))
== Liens ==
OutFile.close()
del OutFile
</syntaxhighlight>
=== Creating a custom render object ===
Apart from standard povray and luxrender view objects, that provide a view of an existing Part object, and that can be inserted in povray and luxrender projects respectively, a third object exist, called RaySegment, that can be inserted either in povray or luxrender projects. That RaySegment object is not linked to any of the FreeCAD objects, and can contain custom povray or luxrender code, that you might wish to insert into your raytracing project. You can also use it, for example, to output your FreeCAD objects a certain way, if you are not happy with the standard way. You can create and use it like this from the python console:
<syntaxhighlight>
myRaytracingProject = FreeCAD.ActiveDocument.PovProject
myCustomRenderObject = FreeCAD.ActiveDocument.addObject("Raytracing::RaySegment","myRenderObject")
myRaytracingProject.addObject(myCustomRenderObject)
myCustomRenderObject.Result = "// Hello from python!"
</syntaxhighlight>
== Links ==


=== POVRay===
=== POVRay===
* [[POV-Ray/fr|POV-Ray]]
* http://www.spiritone.com/~english/cyclopedia/
* http://www.spiritone.com/~english/cyclopedia/
* http://www.povray.org/
* http://www.povray.org/
Line 71: Line 96:


=== Luxrender ===
=== Luxrender ===
* [[LuxRender/fr|LuxRender]]
* http://www.luxrender.net/
* http://www.luxrender.net/


=== Futurs moteurs de rendu possibles à mettre en œuvre ===
=== Future possible renderers to implement ===
* http://www.yafaray.org/
* http://www.yafaray.org/
* http://www.mitsuba-renderer.org/
* http://www.mitsuba-renderer.org/
* http://www.kerkythea.net/
* http://www.kerkythea.net/
* http://www.artofillusion.org/


== Exportation vers Kerkythea ==
----
Bien que l'exportation directe vers le format de fichier XML Kerkythea ne soit pas encore prise en charge, vous pouvez exporter vos objets en tant que fichiers de maillage (.obj), puis les importer dans Kerkythea.
Currently there is a new Renderer Workbench in development to support multiple back-ends such as Lux Renderer and Yafaray. Information for using the development version can be viewed at [[Render_project]]
* Si vous utilisez Kerkythea pour Linux, n'oubliez pas d'installer le WINE-Package (nécessaire à Kerkythea pour Linux)
* vous pouvez convertir vos modèles à l'aide de l'atelier de maillage en maillages, puis exporter ces maillages sous forme de fichiers .obj
* Si votre exportation de maille a entraîné des erreurs (flip de normales, trous ...) vous pouvez tenter votre chance avec [http://www.netfabb.com/downloadcenter.php?basic=1 netfabb studio basic]
: Gratuit pour un usage personnel, disponible pour Windows, Linux et Mac OSX.
: Il dispose d'outils de réparation standard qui vous réparera le modèle dans la plupart des cas.
* Un autre bon programme pour l'analyse/réparation de maillage est [http://sourceforge.net/projects/meshlab/ Meshlab]
: Open Source, disponible pour Windows, Linux et Mac OSX.
: Il dispose d'outils de réparation standard qui vous permettront de réparer votre modèle dans la plupart des cas (combler les trous, réorienter les normales, etc.)
* vous pouvez utiliser "make compound" puis "make single copy" ou vous pouvez fusionner des solides pour les regrouper avant de les convertir en maillages
* N'oubliez pas de définir dans Kerkythea un facteur d'import de 0.001 pour obj-modeler, puisque Kerkythea s'attend à ce que le fichier obj soit en m (mais le schéma d'unités standard dans FreeCAD est mm)
: Dans WIndows 7 Kerkythea 64 bits ne semble pas pouvoir enregistrer ces paramètres.
: Alors rappelez-vous de le faire chaque fois que vous démarrez Kerkythea
* Si vous importez plusieurs objets dans Kerkythea, vous pouvez utiliser la commande "Fichier → Fusionner" dans Kerkythea


<span id="Development"></span>
For Development status of the Render Module look here [[Raytracing_project]]
== Développement ==


Ces pages font référence au nouveau plan de travail, programmé en Python, destiné à remplacer le plan de travail Raytracing actuel.
== Templates ==
* [https://github.com/FreeCAD/FreeCAD-render Render Workbench]
FreeCAD comes with a couple of default templates for povray and luxrender, but you can easily create your own. All you need to do is to create a scene file for the given renderer, then edit it manually with a text editor to insert special tags that FreeCAD will recognize and where it will insert its contents (camera and objects data)
* [https://forum.freecadweb.org/viewtopic.php?f=9&t=25933 Render Workbench] (annonce uniquement, pas de discussion)
* [https://forum.freecadweb.org/viewtopic.php?t=39168 Améliorations de FreeCAD Renderer Workbench]


=== Povray ===
Povray scene files (with extension .pov) can be created manually with a text editor (povray is made primarily to be used as a scripting language), but also with a wide range of 3D applications, such as [http://www.blender.org blender]. On the [http://www.povray.org/ povray website] you can find further information and a list of applications able to produce .pov files.


{{Docnav
When you have a .pov file ready, you need to open it with a text editor, and do two operations:
|
# Strip out the camera information, because FreeCAD will place its own camera data. To do so, locate a text block like this: <tt>camera { ... }</tt>, which describes the camera parameters, and delete it (or put "//" in front of each line to comment them out).
|
# Insert the following line somewhere: <tt>//RaytracingContent</tt>. This is where FreeCAD will insert its contents (camera and objects data). You can, for example, put this line at the very end of the file.
|IconL=
|IconR=
}}


{{Raytracing Tools navi{{#translation:}}}}
Note that FreeCAD will also add some declarations, that you can use in your template, after the <tt>//RaytracingContent</tt> tag. These are:
{{Userdocnavi{{#translation:}}}}
* cam_location: the location of the camera
[[Category:Obsolete Workbenches{{#translation:}}]]
* cam_look_at: the location of the target point of the camera
* cam_sky: the up vector of the camera.
* cam_angle: the angle of the camera

If you want, for example, to place a lamp above the camera, you can use this:
<syntaxhighlight>
light_source {
cam_location + cam_angle * 100
color rgb <10, 10, 10>
}
</syntaxhighlight>
=== Luxrender ===
Luxrender scene files (with extension.lxs) can either be single files, or a master .lxs file that includes world definition (.lxw), material definition (.lxm) and geometry definition (.lxo) files. You can work with both styles, but it is also easy to transform a group of 4 files in a single .lxs file, by copying the contents of each .lxw, .lxm and .lxo file and pasting it at the point where that file is inserted in the master .lxs file.

Luxrender scene files are hard to produce by hand, but are easy to produce with many 3D applications such as [http://www.blender.org blender]. On the [http://www.luxrender.net luxrender website], you'll find more information and plugins for the main 3D applications out there.

If you will work with separated .lxw, .lxm and .lxo files, beware that the final .lxs exported by FreeCAD might be at a different location than the template file, and therefore these files might not be found by Luxrender at render time. In this case you should or copy these files to the location of your final file, or edit their paths in the exported .lxs file.

If you are exporting a scene file from blender, and wish to merge everything into one single file, you will need to perform one step before exporting: By default, the luxrender exporter in blender exports all mesh geometry as separate .ply files, instead of placing the mesh geometry directly inside the .lxo file. To change that behaviour, you need to select each of your meshes in blender, go to the "mesh" tab and set the option "export as" to "luxrender mesh" for each one of them.

After you have your scene file ready, to turn it into a FreeCAD template, you need to perform the following steps:
# Locate the camera position, a single line that begins with <tt>LookAt</tt>, and delete it (or place a "#" at the beginning of the line to comment it out)
# At that place, insert the following line: <tt>#RaytracingCamera</tt>
# At a desired point (for example just after the end of the materials definition, before the geometry information, or at the very end, just before the final <tt>WorldEnd</tt> line, insert the following line: <tt>#RaytracingContent</tt>. That is where FreeCAD will insert its own objects.

Note that in luxrender, the objects stored in a scene file can define transformation matrixes, that perform location, rotation or scaling operations. These matrixes can stack and affect everything that come after them, so, by placing your <tt>#RaytracingContent</tt> tag at the end of the file, you might see your FreeCAD objects affected by a transformation matrix placed earlier in the template. To make sure that this doesn't happen, place your <tt>#RaytracingContent</tt> tag before any other geometry object present in the template. FreeCAD itself won't define any of those transformation matrixes.

{{docnav|Drawing Module|Image Module}}

[[Category:User Documentation]]
{{clear}}
<languages/>

Latest revision as of 17:41, 3 May 2023

L'atelier Raytracing n'est plus inclus depuis la version 0.20.
L'atelier externe Render peut être utilisé à la place.
Icône de l'atelier Raytracing

Introduction

L' atelier Raytracing est utilisé pour générer des images photoréalistes de vos modèles en les interprétant avec un moteur de rendu externe.

L'atelier Raytracing fonctionne avec des modèles, qui sont des fichiers de projet définissant une scène pour votre modèle 3D. Vous pouvez placer des lumières et des géométries telles que des plans de sol. Il contient également des espaces réservés pour la position de la caméra et pour les informations sur les matériaux des objets de la scène. Le projet peut ensuite être exporté dans un fichier prêt à être restitué, ou directement dans FreeCAD.

Actuellement, deux moteurs de rendu sont pris en charge : POV-Ray et LuxRender. Pour être en mesure d'effectuer un rendu à partir de FreeCAD, au moins un de ces programmes doit être installé et configuré dans votre système. Cependant, si aucun programme de rendu n'est installé, vous pourrez toujours exporter un fichier de projet pour le rendre à un autre moment.

L'atelier Raytracing est obsolète, l'atelier externe Render le remplace. Néanmoins, les informations contenues dans cette page sont généralement utiles pour le nouvel atelier car les deux fonctionnent basiquement de la même manière.

Déroulement typique du travail

  1. Créez ou ouvrez un projet dans FreeCAD, ajouter quelques objets solides Part ou PartDesign; le maillage n'est actuellement pas pris en charge.
  2. Créez un projet de Raytracing (povray ou luxrender)
  3. Sélectionnez les objets que vous souhaitez ajouter au projet Raytracing et ajoutez-les au projet avec l'outil "Insert Part"
  4. Exportez le fichier projet ou créer le rendu directement



Le flux de travail de l'atelier Raytracing; l'atelier prépare un fichier de projet à partir d'un modèle donné, puis appelle un programme externe pour produire le rendu réel de la scène. Le rendu externe peut être utilisé indépendamment de FreeCAD.

Outils

Outils de projet

Ce sont les principaux outils d’exportation de votre travail 3D vers des rendus externes.

Utilitaires

Ce sont des outils auxiliaires pour effectuer manuellement des tâches spécifiques.

Préférences

  • Préférences: Préférences disponibles pour les outils Raytracing.

Tutorials

Création manuelle d'un fichier povray

Les outils utilitaires décrits ci-dessus vous permettent d'exporter l'affichage 3D actuel et tout son contenu dans un fichier Povray. Tout d'abord, vous devez charger ou créer vos données CAO et positionner l'orientation de la vue 3D que vous le souhaitez. Puis choisissez "Utilitaires → Exporter la vue..." dans le menu de raytracing.

Donnez un emplacement pour enregistrer le fichier *.pov. Après cela vous pouvez l'ouvrir dans Povray et obtenir le rendu :

Comme d'habitude dans un rendu vous pouvez faire de grandes et belles photos :

Script

Voir Raytracing API exemples pour plus d'informations sur l'écriture de scènes par programmation.

Liens

POVRay

Luxrender

Futurs moteurs de rendu possibles à mettre en œuvre

Exportation vers Kerkythea

Bien que l'exportation directe vers le format de fichier XML Kerkythea ne soit pas encore prise en charge, vous pouvez exporter vos objets en tant que fichiers de maillage (.obj), puis les importer dans Kerkythea.

  • Si vous utilisez Kerkythea pour Linux, n'oubliez pas d'installer le WINE-Package (nécessaire à Kerkythea pour Linux)
  • vous pouvez convertir vos modèles à l'aide de l'atelier de maillage en maillages, puis exporter ces maillages sous forme de fichiers .obj
  • Si votre exportation de maille a entraîné des erreurs (flip de normales, trous ...) vous pouvez tenter votre chance avec netfabb studio basic
Gratuit pour un usage personnel, disponible pour Windows, Linux et Mac OSX.
Il dispose d'outils de réparation standard qui vous réparera le modèle dans la plupart des cas.
  • Un autre bon programme pour l'analyse/réparation de maillage est Meshlab
Open Source, disponible pour Windows, Linux et Mac OSX.
Il dispose d'outils de réparation standard qui vous permettront de réparer votre modèle dans la plupart des cas (combler les trous, réorienter les normales, etc.)
  • vous pouvez utiliser "make compound" puis "make single copy" ou vous pouvez fusionner des solides pour les regrouper avant de les convertir en maillages
  • N'oubliez pas de définir dans Kerkythea un facteur d'import de 0.001 pour obj-modeler, puisque Kerkythea s'attend à ce que le fichier obj soit en m (mais le schéma d'unités standard dans FreeCAD est mm)
Dans WIndows 7 Kerkythea 64 bits ne semble pas pouvoir enregistrer ces paramètres.
Alors rappelez-vous de le faire chaque fois que vous démarrez Kerkythea
  • Si vous importez plusieurs objets dans Kerkythea, vous pouvez utiliser la commande "Fichier → Fusionner" dans Kerkythea

Développement

Ces pages font référence au nouveau plan de travail, programmé en Python, destiné à remplacer le plan de travail Raytracing actuel.