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!
The_Raytracers
Posts: 46
Joined: Tue Jul 14, 2020 4:05 pm

Re: New Raytracing Workbench: POV-Ray-Rendering

Post by The_Raytracers »

david69 wrote: Thu Jun 02, 2022 8:48 pm as I was translating the GUI under Crowdin, it appears some of the commands for translation are not available on Crowdin.
for ex:
Raytracing>New POV-Ray project>the three commands
and same thing for LuxRender
Hi david,
I think, you have posted in the wrong thread?! :)
The_Raytracers
Posts: 46
Joined: Tue Jul 14, 2020 4:05 pm

Re: New Raytracing Workbench: POV-Ray-Rendering

Post by The_Raytracers »

Hi,
Zoltan wrote: Thu Jun 02, 2022 10:10 pm Thanks, that's a useful method for other use cases as well! It works well with the point light and area light. However, when I apply it to a spotlight, it does not point to the correct direction. Could you please test it yourself?
Does the final result have a wrong spotlight or is the spotlight only displayed wrongly in the FreeCAD window (since there were some problems with displaying spotlights in the past already)?

Zoltan wrote: Thu Jun 02, 2022 10:10 pm My other question is related to mesh resolution. My surfaces are B-spline surfaces, which are not supported directly (would it be difficult to implement?). Rather, the surfaces are first meshed. How can I change the mesh density? In its current form, it is very crude, leading to an ugly result.
Yes, you can adjust the mesh resolution by selecting the object, going into the "View" tab of the object properties and change the values of "Angular Deflection" and "Deviation", they are used by the workbench when creating the mesh.
I'm not that familiar with B-splines, so I don't know how hard it would be to implement them, I can look into it though :)

Zoltan wrote: Thu Jun 02, 2022 10:10 pm Finally, I would like to know if it is possible to keep showing the surface edges during rendering (cf. other figure attached).
original.png
rendered.png
As far as I know, there is no option to keep showing the surface edges during rendering since POV-Ray focused on rendering and not modeling. If it's really important maybe you can try to sweep a small circle along the edges and give the sweep a dark color but I admit that this is a very crappy solution :?
Zoltan
Posts: 62
Joined: Wed Jul 07, 2021 10:08 am

Re: New Raytracing Workbench: POV-Ray-Rendering

Post by Zoltan »

Hi,
The_Raytracers wrote: Sun Jun 05, 2022 3:30 pm Does the final result have a wrong spotlight or is the spotlight only displayed wrongly in the FreeCAD window (since there were some problems with displaying spotlights in the past already)?
I checked it by placing the light sources "below" the geometry. First test: spotlight. Apparently, the object is not lit.
spot_light.png
spot_light.png (11.33 KiB) Viewed 2990 times
Then I used area light at the same placement as the spotlight. Here, the rendered result is believable.
area_light.png
area_light.png (74.1 KiB) Viewed 2990 times
For reference, here is the FreeCAD-rendered result, where the light source seems to coincide with the camera view.
model.png
model.png (43.1 KiB) Viewed 2990 times
The_Raytracers wrote: Sun Jun 05, 2022 3:30 pm Yes, you can adjust the mesh resolution by selecting the object, going into the "View" tab of the object properties and change the values of "Angular Deflection" and "Deviation", they are used by the workbench when creating the mesh.
It greatly improved the result. However, the minimum value is 5° for the angular deflection and 0.05 for the deviation. Is there a (possibly undocumented) way to go below these values?
The_Raytracers wrote: Sun Jun 05, 2022 3:30 pm I'm not that familiar with B-splines, so I don't know how hard it would be to implement them, I can look into it though :)
Thank you, that would be great. Custom objects are represented by B-spline curves and surfaces. If your rendering approach worked, many people using the Curves workbench could benefit from it.
The_Raytracers wrote: Sun Jun 05, 2022 3:30 pm As far as I know, there is no option to keep showing the surface edges during rendering since POV-Ray focused on rendering and not modeling. If it's really important maybe you can try to sweep a small circle along the edges and give the sweep a dark color but I admit that this is a very crappy solution :?
Another solution is to associate different textures with the different surfaces.
Last edited by Zoltan on Sun Jun 05, 2022 6:08 pm, edited 1 time in total.
david69
Veteran
Posts: 1773
Joined: Wed Jan 01, 2014 7:48 pm

Re: New Raytracing Workbench: POV-Ray-Rendering

Post by david69 »

The_Raytracers wrote: Sun Jun 05, 2022 3:23 pm
david69 wrote: Thu Jun 02, 2022 8:48 pm as I was translating the GUI under Crowdin, it appears some of the commands for translation are not available on Crowdin.
...
Hi david,
I think, you have posted in the wrong thread?! :)
right! thank you to notify me.
The_Raytracers
Posts: 46
Joined: Tue Jul 14, 2020 4:05 pm

Re: New Raytracing Workbench: POV-Ray-Rendering

Post by The_Raytracers »

Hi Zoltan,
Zoltan wrote: Sun Jun 05, 2022 4:18 pm I checked it by placing the light sources "below" the geometry. First test: spotlight. Apparently, the object is not lit.
spot_light.png
Then I used area light at the same placement as the spotlight. Here, the rendered result is believable.
area_light.png
For reference, here is the FreeCAD-rendered result, where the light source seems to coincide with the camera view.
model.png
Could you share the macro code you used so I can be sure, I'm doing the same thing like you? I guess there is something wrong in the spotlight code...
Zoltan wrote: Sun Jun 05, 2022 4:18 pm However, the minimum value is 5° for the angular deflection and 0.05 for the deviation. Is there a (possibly undocumented) way to go below these values?
Here, in my FreeCAD with the following version I can lower these values down to 1° and 0.01. But unfortunately I also don't know a way to go below these values, even by setting the values per console doesn't work.

Code: Select all

OS: Linux Mint 20.1 (X-Cinnamon/cinnamon)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.
Build type: Release
Branch: unknown
Hash: 0d9536ed3e8c7f40197b5606e1b7873625e1d6fe
Python version: 3.8.10
Qt version: 5.12.8
Coin version: 4.0.0
OCC version: 7.5.2
Locale: German/Germany (de_DE)
Zoltan
Posts: 62
Joined: Wed Jul 07, 2021 10:08 am

Re: New Raytracing Workbench: POV-Ray-Rendering

Post by Zoltan »

The_Raytracers wrote: Tue Jun 07, 2022 5:20 pm Could you share the macro code you used so I can be sure, I'm doing the same thing like you? I guess there is something wrong in the spotlight code...
See the macro attached. The spotlight does not point to the right direction because
  • if you deactivate the spotlight, it does not change the rendered view
  • if you deactivate the point light, the object is not lit.
The_Raytracers wrote: Tue Jun 07, 2022 5:20 pm Here, in my FreeCAD with the following version I can lower these values down to 1° and 0.01. But unfortunately I also don't know a way to go below these values, even by setting the values per console doesn't work.

Code: Select all

OS: Linux Mint 20.1 (X-Cinnamon/cinnamon)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.
Build type: Release
Branch: unknown
Hash: 0d9536ed3e8c7f40197b5606e1b7873625e1d6fe
Python version: 3.8.10
Qt version: 5.12.8
Coin version: 4.0.0
OCC version: 7.5.2
Locale: German/Germany (de_DE)
My FreeCAD version is

Code: Select all

OS: Ubuntu 18.04.6 LTS (ubuntu:GNOME/ubuntu)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 2021.615.24301 +3747 (Git) AppImage
Build type: Release
Branch: LinkDaily
Hash: ecbfba008c481db4cb17bf8bd514b2d12690a8e5
Python version: 3.9.4
Qt version: 5.12.9
Coin version: 4.0.1
OCC version: 7.5.2
Locale: English/United States (en_US)
Probably the newer releases, see e.g. this video, support finer meshes...
Attachments
spotlight_test.FCMacro
(708 Bytes) Downloaded 56 times
The_Raytracers
Posts: 46
Joined: Tue Jul 14, 2020 4:05 pm

Re: New Raytracing Workbench: POV-Ray-Rendering

Post by The_Raytracers »

Zoltan wrote: Tue Jun 07, 2022 6:37 pm ...
Hi Zoltan,
as far as I understand, there is no bug in the code, it's just that the spotlight points to -y and therefore it has to be rotated 90° around the x-axis to create the desired result (what is done if you rotate the spotlight with the "Transform" tool). Unfortunately I don't know how to do this with Python :roll:

Best regards
Zoltan
Posts: 62
Joined: Wed Jul 07, 2021 10:08 am

Re: New Raytracing Workbench: POV-Ray-Rendering

Post by Zoltan »

The_Raytracers wrote: Fri Jun 10, 2022 5:38 pm as far as I understand, there is no bug in the code, it's just that the spotlight points to -y and therefore it has to be rotated 90° around the x-axis to create the desired result (what is done if you rotate the spotlight with the "Transform" tool).
Shouldn't an automatic light source positioning feature be added to your plugin (the same strategy as for the camera, which takes into account the current viewpoint)?

The_Raytracers wrote: Fri Jun 10, 2022 5:38 pm Unfortunately I don't know how to do this with Python :roll:
I do know it. If this rotation is consistently required (i.e. in all the cases, 90° rotation must be performed around the x-axis), I can help you implement it programmatically.
The_Raytracers
Posts: 46
Joined: Tue Jul 14, 2020 4:05 pm

Re: New Raytracing Workbench: POV-Ray-Rendering

Post by The_Raytracers »

Zoltan wrote: Fri Jun 10, 2022 6:43 pm Shouldn't an automatic light source positioning feature be added to your plugin (the same strategy as for the camera, which takes into account the current viewpoint)?
You mean, that the lights are positioned by the user and then during rendering the position and rotation of the camera is added to the lights? I think that is indeed a good idea! What do you think about an option for the lights to be positioned relative to the camera (on some models you might want to have both)?
Zoltan wrote: Fri Jun 10, 2022 6:43 pm
The_Raytracers wrote: Fri Jun 10, 2022 5:38 pm Unfortunately I don't know how to do this with Python :roll:
I do know it. If this rotation is consistently required (i.e. in all the cases, 90° rotation must be performed around the x-axis), I can help you implement it programmatically.
Thank you, I'm not that deep into the mathematics of rotation (FreeCAD uses quaternions to represent the rotation) to implement it on the FreeCAD side. But if you want something like I sketched above this would be on the POV-Ray side where the rotation is handled a bit more intuitively.

Thanks again for your great suggestion!
Zoltan
Posts: 62
Joined: Wed Jul 07, 2021 10:08 am

Re: New Raytracing Workbench: POV-Ray-Rendering

Post by Zoltan »

The_Raytracers wrote: Sat Jun 11, 2022 2:17 pm You mean, that the lights are positioned by the user and then during rendering the position and rotation of the camera is added to the lights? I think that is indeed a good idea! What do you think about an option for the lights to be positioned relative to the camera (on some models you might want to have both)?
I was thinking of something simpler:
  • The camera setting would be left as it is, i.e. take the current view.
  • As for the lights: when the user clicks on the icon of any of the three light source types, the light source would be positioned based on the current view.
The user could then set up the scene intuitively and quickly:
  1. The user positions the 3D scene of FreeCAD based on where he would like the light source to be placed.
  2. The user clicks on the icon of one of the light sources. The light object (call it obj) is constructed with the current view, i.e.

    Code: Select all

    obj.Placement = Gui.ActiveDocument.ActiveView.viewPosition()
  3. The user may repeat steps 1 and 2 with (possibly different) other light sources, if he wants to add more.
  4. When the desired lights are set up, he clicks on the camera icon, and everything goes on as before.
In my opinion, this workflow is intuitive and also requires minimal code modification: the only thing that would change is the initialization of the light by adding a single like of code,

Code: Select all

obj.Placement = Gui.ActiveDocument.ActiveView.viewPosition()
The_Raytracers wrote: Sat Jun 11, 2022 2:17 pm Thank you, I'm not that deep into the mathematics of rotation (FreeCAD uses quaternions to represent the rotation) to implement it on the FreeCAD side. But if you want something like I sketched above this would be on the POV-Ray side where the rotation is handled a bit more intuitively.
I don't know how you construct the spotlight and why it is pointing to another direction than the area light. Setting the direction of the spotlight should be no different from that of the area light. As you could see in my macro I attached previously, setting the placement (i.e. the position and the direction) of the lights is done with the code

Code: Select all

obj.Placement = Gui.ActiveDocument.ActiveView.viewPosition()
.
Post Reply