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 »

Zoltan wrote: Sun Jun 12, 2022 7:34 am 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.
Yes, that's also a good idea. But I would make this optional since it is quite uncommon that objects are automatically placed at the camera. Therefore I would suggest a button that places all selected light sources to the camera (if no light source is selected, all lights will be moved). Do you agree?
Zoltan wrote: Sun Jun 12, 2022 7:34 am 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()
.
I also don't know why the spotlight points to -y, it doesn't seem like a reasonable choice... But I figured out how to apply the 90° rotation in FreeCAD so this also wouldn't be a problem anymore.
Zoltan
Posts: 62
Joined: Wed Jul 07, 2021 10:08 am

Re: New Raytracing Workbench: POV-Ray-Rendering

Post by Zoltan »

The_Raytracers wrote: Sun Jun 12, 2022 3:50 pm But I would make this optional since it is quite uncommon that objects are automatically placed at the camera. Therefore I would suggest a button that places all selected light sources to the camera (if no light source is selected, all lights will be moved). Do you agree?
By what logic do you currently place the light sources?
  • If you have a reasonable initial placement for the light, then leave it as it is. Then repositioning the light according to the current camera view could be an optional choice, as you suggested (i.e. the user selects the lights he wants to reposition according to the current view, and then presses a button).
  • If you have no preferred initial placement for the light, the current camera view would be a good default choice. In this case, there is no need to add a button to the user interface because the user selects the preferred view before allocating the light source.
The_Raytracers wrote: Sun Jun 12, 2022 3:50 pm I also don't know why the spotlight points to -y, it doesn't seem like a reasonable choice... But I figured out how to apply the 90° rotation in FreeCAD so this also wouldn't be a problem anymore.
Fine, if you solved it. However, it would be worthwhile to understand why this "anomaly" happens with the spotlight, so as to avoid further surprises. Once I have some time, I can look into the code. Is this the active repository: https://gitlab.com/usbhub/exporttopovray (I don't see new commits) ?
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: Mon Jun 13, 2022 7:12 am ...
Hi,
I attached a small macro (and a rudimentary icon for it) that places all selected lights (indeed all selected objects) to the camera. If you find any bugs, please tell me :)

The reason for default direction of the spotlight is the line "point_at <0, -1, 0>". As I mentioned, I don't know why I chose this direction, it doesn't seem reasonable but cannot be changed now since this would break existing models with spotlights.

We have two repositories. Initially we used the GitLab repo but there were problems with GitLab and the Addon Manager and therefore we also added the code to GitHub.

Best regards!
Attachments
macro.svg
(5.74 KiB) Downloaded 64 times
PositionToCamera.FCMacro
(492 Bytes) Downloaded 69 times
Zoltan
Posts: 62
Joined: Wed Jul 07, 2021 10:08 am

Re: New Raytracing Workbench: POV-Ray-Rendering

Post by Zoltan »

The_Raytracers wrote: Sun Jun 19, 2022 11:19 am I attached a small macro (and a rudimentary icon for it) that places all selected lights (indeed all selected objects) to the camera. If you find any bugs, please tell me :)
Hello,

I like the icon. I tested your macro with different selection scenarios. It works well, however, your approach is intrusive: if the user selects a custom object, which has a "Part::FeaturePython" type (happens for many custom objects!), it will transform that object too. To avoid this, I modified your script so that it changes the placement for light objects only.
PositionToCamera_mod.FCMacro
(762 Bytes) Downloaded 70 times

The_Raytracers wrote: Sun Jun 19, 2022 11:19 am The reason for default direction of the spotlight is the line "point_at <0, -1, 0>". As I mentioned, I don't know why I chose this direction, it doesn't seem reasonable but cannot be changed now since this would break existing models with spotlights.
When (or if) you introduce a new version of the workbench that breaks backward compatibility, you can fix this orientation issue as well...
The_Raytracers
Posts: 46
Joined: Tue Jul 14, 2020 4:05 pm

Re: New Raytracing Workbench: POV-Ray-Rendering

Post by The_Raytracers »

Hi all,
today was our presentation on the FreeCAD Users Conference 2023, thanks for all who participated :)
I attached the files we created.
Cheers
The Raytracers
Attachments
Fish_with_HDRI.ini
(913 Bytes) Downloaded 57 times
Fish with HDRI.FCStd
(298.81 KiB) Downloaded 54 times
User avatar
Brodie
Posts: 9
Joined: Tue Nov 05, 2019 11:39 am
Location: Australia
Contact:

Re: New Raytracing Workbench: POV-Ray-Rendering

Post by Brodie »

I really enjoyed this one!
Thanks for sharing the files too.
The_Raytracers
Posts: 46
Joined: Tue Jul 14, 2020 4:05 pm

Re: New Raytracing Workbench: POV-Ray-Rendering

Post by The_Raytracers »

Hi all,
just a small information for you: We implemented hybrid textures that take information from the "FreeCAD texture" (e.g. the color of the object in FreeCAD) and combine this with a POV-Ray material. For instance the "Gradient Peel" texture now takes the color from the FreeCAD object, see the attachment below.

Hope you enjoy :)
Attachments
Hybrid Textures Screenshot.png
Hybrid Textures Screenshot.png (400.78 KiB) Viewed 2961 times
Post Reply