Difference between revisions of "Raytracing Module/sv"

From FreeCAD Documentation
Jump to: navigation, search
(Created page with "{{docnav/sv|Drawing Module/sv|Draft Module/sv}}")
(Updating to match new version of source page)
 
(15 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
<languages/>
 +
{{docnav
 +
|[[Points Workbench|Points Workbench]]
 +
|[[Reverse Engineering Workbench|Reverse Engineering Workbench]]
 +
|IconL=PointsWorkbench.svg
 +
|IconR=ReverseEngineeringWorkbench.svg
 +
}}
 +
 +
[[Image:Workbench_Raytracing.svg|64px]]
 +
 +
<div class="mw-translate-fuzzy">
 
Denna modul är tänkt att skicka innehållet i din scen till en extern [http://sv.wikipedia.org/wiki/Rendering rendererare], för att generera fotorealistiska bilder på ditt arbete. Renderingsmodulen är fortfarande i ett mycket tidigt skede, så du har inte så många tillgängliga alternativ för tillfället. För närvarande finns endast ett grundläggande verktygsset för att exportera Del objekt som [http://sv.wikipedia.org/wiki/POV-Ray POV-ray] filer. Dessa filer kan sedan laddas i POV-ray och renderas.
 
Denna modul är tänkt att skicka innehållet i din scen till en extern [http://sv.wikipedia.org/wiki/Rendering rendererare], för att generera fotorealistiska bilder på ditt arbete. Renderingsmodulen är fortfarande i ett mycket tidigt skede, så du har inte så många tillgängliga alternativ för tillfället. För närvarande finns endast ett grundläggande verktygsset för att exportera Del objekt som [http://sv.wikipedia.org/wiki/POV-Ray POV-ray] filer. Dessa filer kan sedan laddas i POV-ray och renderas.
 +
</div>
 +
 +
The Raytracing Workbench works with [[Raytracing templates|templates]], which are project files that define a scene for your 3D model. You can place lights and geometry such as ground planes, and it also contains placeholders for the position of the camera, and for the material information of the objects in the scene. The project can then be exported to a ready-to-render file, or be rendered directly within FreeCAD.
 +
 +
Currently, 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 from within FreeCAD, at least one of these programs must be installed and configured in your system. However, if no renderer is installed, you will still be able to export a project file to be rendered at another time.
 +
 +
A new Render Workbench has been 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|Render project]]. For development status of the Render Module look into the [[Raytracing project|Raytracing project]].
  
 +
{{TOCright}}
 
[[Image:Raytracing_example.jpg|1024px]]
 
[[Image:Raytracing_example.jpg|1024px]]
  
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.
+
== Typical workflow ==
 +
# Create or open a FreeCAD project, add some solid objects ([[Part Module|Part-based]] or [[PartDesign Workbench|PartDesign-based]]); meshes are currently not supported.
 +
# Create a Raytracing project (povray or luxrender).
 +
# Select the objects that you wish to add to the Raytracing project and add them.
 +
# Export the project file or render it directly.
 +
 
  
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]]
 +
 
 +
 
 +
{{Caption|Workflow of the Raytracing Workbench; the workbench prepares a project file from a given template, and then calls an external program to produce the actual rendering of the scene. The external renderer can be used independently of FreeCAD.}}
  
 
=== Gränssnittsverktyg ===
 
=== Gränssnittsverktyg ===
  
{{Raytracing Tools/sv}}
+
===Project tools===
 +
 
 +
These are the main tools for exporting your 3D work to external renderers.
 +
* [[Image:Raytracing_New.png|32px]] [[Raytracing_New|New PovRay project]]: Insert new PovRay project in the document
 +
* [[Image:Raytracing_Lux.png|32px]] [[Raytracing_Lux|New LuxRender project]]: Insert new LuxRender project in the document
 +
* [[Image:Raytracing_InsertPart.png|32px]] [[Raytracing_InsertPart|Insert part]]: Insert a view of a Part in a raytracing project
 +
* [[Image:Raytracing_ResetCamera.png|32px]] [[Raytracing_ResetCamera|Reset camera]]: Matches the camera position of a raytracing project to the current view
 +
* [[Image:Raytracing_ExportProject.png|32px]] [[Raytracing_ExportProject|Export project]]: Exports a raytracing project to a scene file for rendering in an external renderer
 +
* [[Image:Raytracing_Render.png|32px]] [[Raytracing_Render|Render]]: Renders a raytracing project with an external renderer
 +
 
 +
===Utilities===
 +
 
 +
These are helper tools to perform specific tasks manually.
 +
* [[Image:Raytracing_Export.png|32px]] [[Raytracing_Export|Export view to povray]]: Write the active 3D view with camera and all its content to a povray file
 +
* [[Image:Raytracing_Camera.png|32px]] [[Raytracing_Camera|Export camera to povray]]: Export the camera position of the active 3D view in POV-Ray format to a file
 +
* [[Image:Raytracing_Part.png|32px]] [[Raytracing_Part|Export part to povray]]: Write the selected Part (object) as a povray file
 +
 
 +
== Preferences ==
 +
 
 +
* [[Image:Preferences-raytracing.svg|32px]] [[Raytracing_Preferences|Preferences]]: Preferences available in for the Raytracing tools.
  
== Typical workflow ==
+
== Tutorials ==
# Create or open a FreeCAD project, add some [[Part Module|Part-based]] objects (meshes are currently not supported)
+
* [[Raytracing_tutorial|Basic Raytracing tutorial]]
# Create a Raytracing project (luxrender or povray)
+
* [[Tutorial FreeCAD POV ray|Intermediate Raytracing tutorial]]
# 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
 
  
 
== Creating a povray file manually ==
 
== Creating a povray file manually ==
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.
+
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.
  
 
[[Image:FreeCAD_Raytracing.jpg|center]]
 
[[Image:FreeCAD_Raytracing.jpg|center]]
  
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:
+
You will be asked for a location to save the resulting *.pov file. After that you can open it in [http://www.povray.org/ Povray] and render:
 
 
 
[[Image:Povray.jpg|center]]
 
[[Image:Povray.jpg|center]]
  
As usual in a rendererer you can make big and nice pictures:
+
As usual in a renderer you can make big and nice pictures:
 
+
[[Image:Scharniergreifer_render.jpg|center|800px]]
[[Image:Scharniergreifer_render.jpg|1024px]]
 
  
 
=== Skript ===
 
=== Skript ===
  
=== Outputting render files ===
+
See the [[Raytracing API example|Raytracing API example]] for information on writing scenes programmatically.
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.
 
  
Här ser du hur du använder dessa funktioner i python:
 
<syntaxhighlight>
 
import Raytracing,RaytracingGui
 
OutFile = open('C:/Documents and Settings/jriegel/Desktop/test.pov','w')
 
OutFile.write(open(App.getResourceDir()+'Mod/Raytracing/Templates/ProjectStd.pov').read())
 
OutFile.write(RaytracingGui.povViewCamera())
 
OutFile.write(Raytracing.getPartAsPovray('Box',App.activeDocument().Box.Shape,0.800000,0.800000,0.800000))
 
OutFile.close()
 
del OutFile
 
</syntaxhighlight>
 
And the same for luxrender:
 
<syntaxhighlight>
 
import Raytracing,RaytracingGui
 
OutFile = open('C:/Documents and Settings/jriegel/Desktop/test.lxs','w')
 
OutFile.write(open(App.getResourceDir()+'Mod/Raytracing/Templates/LuxClassic.lxs').read())
 
OutFile.write(RaytracingGui.luxViewCamera())
 
OutFile.write(Raytracing.getPartAsLux('Box',App.activeDocument().Box.Shape,0.800000,0.800000,0.800000))
 
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>
 
 
=== Länkar ===
 
=== Länkar ===
  
Line 77: Line 90:
 
* http://www.mitsuba-renderer.org/
 
* http://www.mitsuba-renderer.org/
 
* http://www.kerkythea.net/
 
* http://www.kerkythea.net/
 +
* http://www.artofillusion.org/
  
----
+
== Exporting to 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]]
+
Although direct export to the Kerkythea XML-File-Format is not supported yet, you can export your Objects as Mesh-Files (.obj) and then import them in Kerkythea.
 
+
* if using Kerkythea for Linux, remember to install the WINE-Package (needed by Kerkythea for Linux to run)
For Development status of the Render Module look here [[Raytracing_project]]
+
* you can convert your models with the help of the mesh workbench to meshes and then export these meshes as .obj-files
 
+
* If your mesh-export resulted in errors (flip of normals, holes ...) you may try your luck with [http://www.netfabb.com/downloadcenter.php?basic=1 netfabb studio basic]
== Templates ==
+
:Free for personal use, available for Windows, Linux and Mac OSX.
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)
+
:It has standard repair tools which will repair you model in most cases.
 
+
* another good program for mesh analysing/repairing is [http://sourceforge.net/projects/meshlab/ Meshlab]
=== Povray ===
+
:Open Source, available for Windows, Linux and Mac OSX.
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.
+
:It has standard repair tools which will repair you model in most cases (fill holes, re-orient normals, etc.)
 
+
* you can use "make compound" and then "make single copy" or you can fuse solids to group them before converting to meshes
When you have a .pov file ready, you need to open it with a text editor, and do two operations:
+
* remember to set in Kerkythea an import-factor of 0.001 for obj-modeler, since Kerkythea expects the obj-file to be in m (but standard units-scheme in FreeCAD is mm)
# 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).
+
:Within WIndows 7 64-bit Kerkythea does not seem to be able to save these settings.
# 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.
+
:So remember to do that each time you start Kerkythea
 +
* if importing multiple objects in Kerkythea you can use the "File → Merge" command in Kerkythea
  
Note that FreeCAD will also add some declarations, that you can use in your template, after the <tt>//RaytracingContent</tt> tag. These are:
+
==Development==
* cam_location: the location of the camera
+
* [[Render_project|Render project]]
* 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.
 
  
 +
<div class="mw-translate-fuzzy">
 
{{docnav/sv|Drawing Module/sv|Draft Module/sv}}
 
{{docnav/sv|Drawing Module/sv|Draft Module/sv}}
 +
</div>
  
[[Category:User Documentation]]
+
{{Raytracing Tools navi}}
{{clear}}
+
{{Userdocnavi}}
<languages/>
+
[[Category:Workbenches]]

Latest revision as of 10:39, 28 October 2019

Other languages:
čeština • ‎Deutsch • ‎English • ‎español • ‎français • ‎hrvatski • ‎Bahasa Indonesia • ‎italiano • ‎日本語 • ‎한국어 • ‎polski • ‎português • ‎português do Brasil • ‎română • ‎русский • ‎svenska • ‎Türkçe • ‎українська • ‎中文 • ‎中文(中国大陆)‎ • ‎中文(台灣)‎

Workbench Raytracing.svg

Denna modul är tänkt att skicka innehållet i din scen till en extern rendererare, för att generera fotorealistiska bilder på ditt arbete. Renderingsmodulen är fortfarande i ett mycket tidigt skede, så du har inte så många tillgängliga alternativ för tillfället. För närvarande finns endast ett grundläggande verktygsset för att exportera Del objekt som POV-ray filer. Dessa filer kan sedan laddas i POV-ray och renderas.

The Raytracing Workbench works with templates, which are project files that define a scene for your 3D model. You can place lights and geometry such as ground planes, and it also contains placeholders for the position of the camera, and for the material information of the objects in the scene. The project can then be exported to a ready-to-render file, or be rendered directly within FreeCAD.

Currently, two renderers are supported: povray and luxrender. To be able to render from within FreeCAD, at least one of these programs must be installed and configured in your system. However, if no renderer is installed, you will still be able to export a project file to be rendered at another time.

A new Render Workbench has been 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. For development status of the Render Module look into the Raytracing project.

Raytracing example.jpg

Typical workflow

  1. Create or open a FreeCAD project, add some solid objects (Part-based or PartDesign-based); meshes are currently not supported.
  2. Create a Raytracing project (povray or luxrender).
  3. Select the objects that you wish to add to the Raytracing project and add them.
  4. Export the project file or render it directly.


Raytracing Workbench workflow.svg


Workflow of the Raytracing Workbench; the workbench prepares a project file from a given template, and then calls an external program to produce the actual rendering of the scene. The external renderer can be used independently of FreeCAD.


Gränssnittsverktyg

Project tools

These are the main tools for exporting your 3D work to external renderers.

  • Raytracing New.png New PovRay project: Insert new PovRay project in the document
  • Raytracing Lux.png New LuxRender project: Insert new LuxRender project in the document
  • Raytracing InsertPart.png Insert part: Insert a view of a Part in a raytracing project
  • Raytracing ResetCamera.png Reset camera: Matches the camera position of a raytracing project to the current view
  • Raytracing ExportProject.png Export project: Exports a raytracing project to a scene file for rendering in an external renderer
  • Raytracing Render.png Render: Renders a raytracing project with an external renderer

Utilities

These are helper tools to perform specific tasks manually.

Preferences

  • Preferences-raytracing.svg Preferences: Preferences available in for the Raytracing tools.

Tutorials

Creating a povray file manually

The utility tools described above allow you to export the current 3D view and all of its content to a 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.

FreeCAD Raytracing.jpg

You will be asked for a location to save the resulting *.pov file. After that you can open it in Povray and render:

Povray.jpg

As usual in a renderer you can make big and nice pictures:

Scharniergreifer render.jpg

Skript

See the Raytracing API example for information on writing scenes programmatically.

Länkar

POVRay

Luxrender

Future possible renderers to implement

Exporting to Kerkythea

Although direct export to the Kerkythea XML-File-Format is not supported yet, you can export your Objects as Mesh-Files (.obj) and then import them in Kerkythea.

  • if using Kerkythea for Linux, remember to install the WINE-Package (needed by Kerkythea for Linux to run)
  • you can convert your models with the help of the mesh workbench to meshes and then export these meshes as .obj-files
  • If your mesh-export resulted in errors (flip of normals, holes ...) you may try your luck with netfabb studio basic
Free for personal use, available for Windows, Linux and Mac OSX.
It has standard repair tools which will repair you model in most cases.
  • another good program for mesh analysing/repairing is Meshlab
Open Source, available for Windows, Linux and Mac OSX.
It has standard repair tools which will repair you model in most cases (fill holes, re-orient normals, etc.)
  • you can use "make compound" and then "make single copy" or you can fuse solids to group them before converting to meshes
  • remember to set in Kerkythea an import-factor of 0.001 for obj-modeler, since Kerkythea expects the obj-file to be in m (but standard units-scheme in FreeCAD is mm)
Within WIndows 7 64-bit Kerkythea does not seem to be able to save these settings.
So remember to do that each time you start Kerkythea
  • if importing multiple objects in Kerkythea you can use the "File → Merge" command in Kerkythea

Development