New Raytracing Workbench: POV-Ray-Rendering

Info about new community or project announcements, implemented features, classes, modules or APIs. Might get technical!
PLEASE DO NOT POST HELP REQUESTS OR OTHER DISCUSSIONS HERE!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
The_Raytracers
Posts: 46
Joined: Tue Jul 14, 2020 4:05 pm

New Raytracing Workbench: POV-Ray-Rendering

Post by The_Raytracers »

Workbench for Exporting & Rendering a FreeCAD Model with POV-Ray

Image

After one year of developing, we're happy to publish a new workbench for creating photorealistic images with POV-Ray. The workbench is aimed at both beginners and advanced users in raytracing. With this workbench you will be able to create easily photorealistic pictures of your model, even if you are not familiar with rendering. If you're an advanced user with more knowledge, you can get the full control about all detailed settings by combining the FreeCAD model with POV-Rays scriptig language.

In contrast to the other rendering solutions of FreeCAD we are focused on using POV-Ray as the only renderer and tryed to support as many POV-Ray features as possible. The workbench uses solid primitives and other mathematic describable objects as long as they are implemented in POV-Ray and translation is not too elaborate in programming. But meshes are also supported so you will always get a result even for not supported objects. (Take a look at Supported.md to see a list of the supported features.)


Features
  • easy applying of textures including a preview
  • easy inserting and configuration of different types of lights
  • easy use of indirect lightning to create realistic images
  • easy inserting of HDRI Environments (is in progress, see post below)
    ⇨ simple handling and operation
  • power users can get the full control about the whole configuration with the user inc file (see Power User Section)
    ⇨ offering all settings for advanced users
  • the model is not converted into meshes, the model will be converted into a mathematical way of describing the object shape, so you will get a better object and a better picture
  • very good readability of the created files → easy editing of these files
  • WYSIWYG - You can pan your model and render and you will get this point of view from FreeCAD
Installation

You can install the workbench via the Addon-Manager easily.
In addition, you will need a POV-Ray installation to run the workbench. For Windows users, the installer can be downloaded from https://www.povray.org/download/, for Linux users it can usually be installed from the package manager. Look up the detailed instructions in the https://wiki.povray.org/content/HowTo:Install_POV if you're on a Mac.

After installing POV-Ray, the last thing you have to do is to tell the workbench, where you installed POV-Ray. To do this, go into the POV-Ray workbench and go to Edit/Preferences/POV-Ray. Under "POV-Ray Executable" you can define, where you installed POV-Ray, this are the standard paths:
  • Windows: C:/Program Files/POV-Ray/v3.7/bin/pvengine64.exe
  • Linux: /usr/bin/povray
  • MacOS: if you know, please let us know, since I have no Mac to look up the path
After that, restart FreeCAD and create pictures of your models :)


Have fun! We are looking forward to your feedback.
Attachments
Workbench_Demo_New.gif
Workbench_Demo_New.gif (477.2 KiB) Viewed 13449 times
Last edited by The_Raytracers on Mon Jun 12, 2023 5:26 pm, edited 6 times in total.
vocx
Veteran
Posts: 5197
Joined: Thu Oct 18, 2018 9:18 pm

Re: New Raytracing Workbench for POV-Ray

Post by vocx »

The_Raytracers wrote: Tue Jul 14, 2020 4:18 pm ...
This workbench should become part of the Addon Manager soon. ...
Can you add this workbench in the appropriate place in external workbenches?

Also, I know it sounds bad to refactor something that should work nice for you, but ideally you should restructure this workbench into the "new style", what we have termed "namespace workbench".

The main difference with this workbench is that your folders should be inside a "freecad" directory. Instead of using InitGui.py, you should have a init_gui.py file. In this way the modules of your workbench don't pollute the global namespace, and all functions and classes are inside the "freecad.raytracing" path, for example. This also makes it easier to install your workbench as a proper Python package that can be installed with pip.

This is explained in this link, https://github.com/FreeCAD/freecad.workbench_starterkit

As for the code itself, I would also recommend you to follow the Python guidelines which specify naming most variables, functions and methods in "snake_case" instead of "camelCase"; the files themselves should also be lowercase, dialog.py, not Dialog.py. In this dialog it seems the graphical user interface is manually crafted. I suggest you create it as a .ui file from QtCreator to reduce the amount of code.
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
The_Raytracers
Posts: 46
Joined: Tue Jul 14, 2020 4:05 pm

Re: New Raytracing Workbench for POV-Ray

Post by The_Raytracers »

vocx wrote: Tue Jul 14, 2020 5:46 pm
The_Raytracers wrote: Tue Jul 14, 2020 4:18 pm ...
This workbench should become part of the Addon Manager soon. ...
Can you add this workbench in the appropriate place in external workbenches?

Also, I know it sounds bad to refactor something that should work nice for you, but ideally you should restructure this workbench into the "new style", what we have termed "namespace workbench".

The main difference with this workbench is that your folders should be inside a "freecad" directory. Instead of using InitGui.py, you should have a init_gui.py file. In this way the modules of your workbench don't pollute the global namespace, and all functions and classes are inside the "freecad.raytracing" path, for example. This also makes it easier to install your workbench as a proper Python package that can be installed with pip.

This is explained in this link, https://github.com/FreeCAD/freecad.workbench_starterkit

As for the code itself, I would also recommend you to follow the Python guidelines which specify naming most variables, functions and methods in "snake_case" instead of "camelCase"; the files themselves should also be lowercase, dialog.py, not Dialog.py. In this dialog it seems the graphical user interface is manually crafted. I suggest you create it as a .ui file from QtCreator to reduce the amount of code.
Hello vocx,
thank you for your reply!

I've sent an PM to get wiki editing permissions :)

The new structure sounds very good, but I saw, it only works with the 0.19 Version or 0.18 with Python3. Because the 0.18 is the current stable release and some installations of 0.18 still use Python2 (my own to example) I would postpone that until more installations use Python3.

I will take a look at the Qt Creator (I hate it, since I had to create the preferences page with it ;) ). I'm currently refactoring Dialog.py because it became very messy, if you want to take a look at it, it is on an own branch. I'm coming more from C++, so I didn't changed my naming conventions, but I can do that (I have the sense, that the naming conventions of python aren't followed by all standard libraries like e.g tempfile, right?). Does anyone know a program like autopep8 to change the names automatically?
The renaming of the python files is done and pushed to the repo.

Greetings,
The_Raytracers
vocx
Veteran
Posts: 5197
Joined: Thu Oct 18, 2018 9:18 pm

Re: New Raytracing Workbench for POV-Ray

Post by vocx »

The_Raytracers wrote: Tue Jul 14, 2020 8:17 pm ...and some installations of 0.18 still use Python2 (my own to example) I would postpone that until more installations use Python3.
In my opinion it is not good to actively support Python 2 at this point. It already reached end of life, so there is no reason a new product should even consider it. I think the majority of FreeCAD users actually use the Python 3 version because it is provided like that in Windows and MacOS, so this isn't a problem for most. Essentially Python 2 is only supported in Linux because it doesn't cost us much; but I always recommend everybody to use the Python 3 version whenever I spot somebody on Python 2 still.

QtCreator is not hard to use; it's pretty simple to create the widgets. Then in your Python code you just need to do something like the following.

Code: Select all

class TaskPanelPOVRay:
     ui_file = "TaskPanel_POV_ray.ui"
     self.form = Gui.PySideUic.loadUi(ui_file)

    self.form.widget_name.setTitle() # or do something
See the files in Mod/Draft/drafttaskpanels to see how we do it.

And not every single Python library uses the conventions but it if they are followed it really helps standardize big projects like this one. I've read that even Qt6 is going to have a more Pythonic interface, at least I expect so for PySide6.
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: New Raytracing Workbench for POV-Ray

Post by Kunda1 »

I'm curious why not integrate this in to the pre-exisiting Render Workbench ? (instead of having it's own workbench)
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
The_Raytracers
Posts: 46
Joined: Tue Jul 14, 2020 4:05 pm

Re: New Raytracing Workbench for POV-Ray

Post by The_Raytracers »

Kunda1 wrote: Tue Jul 14, 2020 8:31 pm I'm curious why not integrate this in to the pre-exisiting Render Workbench ? (instead of having it's own workbench)
I think, we follow another approach than the Render Workbench. We're focusing on one renderer and try to support it as good as possible, while the Render workbench tries to generalize this and support several renderers. In addition, we try to create mathematically perfect objects (this is how it all started with this workbench :) ) to avoid meshes. This reasons lead to different procedures e.g for applying textures.

I not want to say that we definitely shouldn't combine the two workbenches, but there would definitely be a lot of hurdles to overcome.
I think, both approaches have many advantages and disadvantages while none of them have to be better than the other one.

If there is a real interest in combining the best of these two approaches, I think, there is potential to create a solution better than the sum of both single solutions. But we should discuss this in another thread (and I have to talk about that with my developing partner, we created the workbench together).


The_Raytracers
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: New Raytracing Workbench for POV-Ray

Post by Kunda1 »

+1
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
The_Raytracers
Posts: 46
Joined: Tue Jul 14, 2020 4:05 pm

Re: New Raytracing Workbench for POV-Ray

Post by The_Raytracers »

Hello,
we are on the way to support HDRI Environments.
For this, we created another tab in the dialog window. A screenshot is attached, we hope for feedback :)

If someone want to test it: The code is on an extra branch called "environmentTab": https://gitlab.com/usbhub/exporttopovra ... ronmentTab

Greetings
The_Raytracers

PS: The workbench is still not in the Addon Manager because we have problems with our wiki account (it is not possible to log in).
Attachments
environmentTab_screenshot.png
environmentTab_screenshot.png (115.42 KiB) Viewed 14834 times
paullee
Veteran
Posts: 5097
Joined: Wed May 04, 2016 3:58 pm

Re: New Raytracing Workbench for POV-Ray

Post by paullee »

Missed this previously ! Awesome WB !

Wonder also if integration with Blender can be done ?
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: New Raytracing Workbench for POV-Ray

Post by Kunda1 »

The_Raytracers wrote: Fri Aug 28, 2020 7:05 pm PS: The workbench is still not in the Addon Manager because we have problems with our wiki account (it is not possible to log in).
What's your account username ?
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Post Reply