Raytracing Workbench/ro: Difference between revisions

From FreeCAD Documentation
No edit summary
No edit summary
Line 74: Line 74:
* http://www.luxrender.net/
* http://www.luxrender.net/


=== Future possible renderers to implement ===
=== viitoare posiblile randări de implementat ===
* http://www.yafaray.org/
* http://www.yafaray.org/
* http://www.mitsuba-renderer.org/
* http://www.mitsuba-renderer.org/

Revision as of 18:40, 4 August 2018

Atelierul de Iluminare este folosit pentru a genera imagini fotorealiste ale modelelor dvs., făcându-le cu o randare externă. Atelierul de Iluminare funcționează împreună cu modulul templates, permițându-vă să creați un proiect Raytracing în care adăugați vederi ale obiectelor. Proiectul poate fi apoi exportat într-un fișier gata de redare sau poate fi redat direct.

În mod obișnuit, sunt susținute două tipuri de randare: povray și luxrender. Pentru a putea reda direct din FreeCAD, cel puțin unul dintre acestea randări trebuie instalat pe sistemul dvs., iar calea trebuie să fie configurată în preferințele FreeCAD Raytracing. Fără instalarea oricăror elemente de randare, totuși, puteți să exportați un fișier scenă care poate fi folosit ulterior în oricare dintre aceste tipuri de randare sau pe altă mașină.

Atelierul de iluminare funcționează împreună cu modulele templates, care reprezintă fișiere de scenă complete pentru randarea exteriorului dat, inclusiv luminile și eventual geometria suplimentară, cum ar fi planurile de la sol. Aceste fișiere de scenă conțin locașuri, în care FreeCAD va introduce poziția camerei, precum și informații despre geometrie și materiale ale fiecăruia dintre obiectele inserate în proiect. Acest fișier scena modificat este ceea ce este apoi exportat la randarele externe.

Instrumente

Template:Raytracing Tools

Flux de lucru tipic

  1. Creați sau deschideți un proiect FreeCAD, adăugați unele obiecte Part-based (mesh-urile nu sunt acceptate în prezent)
  2. Creați un proiect Raytracing (cu luxrender sau povray)
  3. Selectați obiectele pe care doriți să le adăugați la proiectul raytracing și adăugați-le la proiect cu instrumentul "Inserați o piesă"
  4. Exportați sau afișați direct

Crearea manuală a unui fișier povray

Instrumentele utilitare descrise mai sus vă permit să exportați vizualizarea 3D curentă și întregul conținut al acestuia într-un fișier Povray. În primul rând, trebuie să încărcați sau să creați datele CAD și să poziționați orientarea 3D în orientarea dorită. Apoi alegeți "Utilities-> Export View ..." din meniul raytracing.

Vi se va solicita o locație pentru salvarea fișierului * .pov rezultat. După asta, poți să o deschizi Povray and render:

Ca de obicei, prin randare poți face poze mari și frumoase:

Scripturi

Ieșirea fișierelor de randare

Modulele Raytracing și RaytracingGui oferă mai multe metode pentru a scrie conținutul scenelor ca date povray sau luxrender. Cele mai utile sunt Raytracing.getPartAsPovray () și Raytracing.getPartAsLux () pentru a reanda un obiect FreeCAD Part într-o definiție povray sau luxrender și RaytracingGui.povViewCamera () și RaytracinGui.luxViewCamera () pentru a obține punctul de vedere curent al FreeCAD în Fereastră 3D în format povray sau luxrender.

Iată cum se poate scrie un fișier povray din Python, presupunând că documentul conține un obiect "Box":

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

La fel și pentru luxrender:

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

Crearea unui obiect particularizat de randare

În afară de obiectele standard povray și luxrender care oferă o vizualizare a unui obiect Piesă existent și care pot fi inserate în proiecte povray și luxrender, există un al treilea obiect numit RaySegment, care poate fi inserat fie în proiecte povray, fie în proiecte luxrender. Acest obiect RaySegment nu este conectat la niciunul dintre obiectele FreeCAD și poate conține coduri personalizate sau coduri luxrender, pe care ați putea dori să le inserați în proiectul dvs. de raytracing. De asemenea, îl puteți utiliza, de exemplu, pentru a vă da obiectele FreeCAD într-un anumit mod, dacă nu sunteți mulțumit de modul standard. Puteți să o creați și să o utilizați astfel de pe consola python:

myRaytracingProject = FreeCAD.ActiveDocument.PovProject
myCustomRenderObject = FreeCAD.ActiveDocument.addObject("Raytracing::RaySegment","myRenderObject")
myRaytracingProject.addObject(myCustomRenderObject)
myCustomRenderObject.Result = "// Hello from python!"

Legătuiri

POVRay

Luxrender

viitoare posiblile randări de implementat


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

For Development status of the Render Module look here Raytracing_project

Templates

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)

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 blender. On the povray website you can find further information and a list of applications able to produce .pov files.

When you have a .pov file ready, you need to open it with a text editor, and do two operations:

  1. Strip out the camera information, because FreeCAD will place its own camera data. To do so, locate a text block like this: camera { ... }, which describes the camera parameters, and delete it (or put "//" in front of each line to comment them out).
  2. Insert the following line somewhere: //RaytracingContent. 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.

Note that FreeCAD will also add some declarations, that you can use in your template, after the //RaytracingContent tag. These are:

  • cam_location: the location of the camera
  • 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:

light_source {
 cam_location + cam_angle * 100
 color rgb <10, 10, 10>
}

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 blender. On the 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:

  1. Locate the camera position, a single line that begins with LookAt, and delete it (or place a "#" at the beginning of the line to comment it out)
  2. At that place, insert the following line: #RaytracingCamera
  3. 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 WorldEnd line, insert the following line: #RaytracingContent. 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 #RaytracingContent 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 #RaytracingContent tag before any other geometry object present in the template. FreeCAD itself won't define any of those transformation matrixes.

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

Links


Drawing Module/ro
Image Module/ro