[Renderer Workbench] Lighting

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
howetuft
Posts: 313
Joined: Tue Sep 10, 2019 8:16 pm

Re: [Renderer Workbench] Lighting

Post by howetuft »

Good idea!

So the targets for the lighting effort could be:
- Point Lights (PL)
- Area Lights (AL)
- Image-Based Lighting (IBL)
- Hosek-Wilkie Skylight (HWS)
- A tri-point lighting functionality, based on PL and AL (priority 2)
- Plus a Camera Object (CAM), to meet a need expressed here: https://forum.freecadweb.org/viewtopic.php?f=10&t=40839

I should post soon first PRs for Point Lights and go through other points, but any help is welcome! @nocturnial: yes, your help would be especially precious with HWS (what I just know about the sun is that it should be somewhere above my head during the day...), let me know how you see things.

A point about design: my idea would be to develop all lighting stuff above (PL, AL, IBL, HWS, and even CAM) as objects we could insert freely into rendering projects (and which renderers modules should then convert to renderer-specific formats), with the following characteristics:
- objects would not be render-dependent: e.g. we could have the same HWS or the same CAM used for a Luxcore project and a Blender project
- in a given project, we could have several instances of the same class. It is obvious for PL and AL, but I think we should also consider the possibility, in the same project, to have several HWS, several CAMs etc. that the user could activate/deactivate for a given rendering.
--> Any comments appreciated!
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: [Renderer Workbench] Lighting

Post by Kunda1 »

Very exciting discussion here. These various functionalities integrated will further evolve this powerful workbench. Thank you
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
howetuft
Posts: 313
Joined: Tue Sep 10, 2019 8:16 pm

Re: [Renderer Workbench] Lighting

Post by howetuft »

I finally posted a first PR, which allows a user to add Point Lights in a scene rendering. https://github.com/FreeCAD/FreeCAD-render/pull/18
For the moment, the export only works for Pov-Ray, but I will extend it to other rendering engines in the future.

Usage:
1°) Add a Point Light to the FreeCAD scene with the Arch Texture Workbench. Adjust color, position etc.
2°) Create a view of the Light Point in your rendering project (which must be a POV-Ray project, for the moment), with the Render Workbench
3°) Render!

To illustrate the concept, I made two examples below, in a before/after manner.

Example 1: a simple sphere
First, the scene with the standard lighting template:
PovrayProject92xk7y4_withoutPL.png
PovrayProject92xk7y4_withoutPL.png (33.48 KiB) Viewed 2789 times
And the same after adding a point light on the right above the camera :
PovrayProject92xk7y4_withPL.png
PovrayProject92xk7y4_withPL.png (41.61 KiB) Viewed 2789 times
One can see the following consequences:
  • The object is more lit, which increases the contrast with the background and creates some kind of focus on it.
  • There is specular reflection on the sphere, and a cast shadow behind, which can improve the realism of the rendering.
Example 2: a more complex scene...
I borrowed the model from Yorik, thanks to him.

Standard lighting template:
PovrayProject10jb6w0p_withoutPL.png
PovrayProject10jb6w0p_withoutPL.png (150.94 KiB) Viewed 2789 times
The same with an added point light in the right and above the camera :
PovrayProject10jb6w0p_withPL.png
PovrayProject10jb6w0p_withPL.png (169.05 KiB) Viewed 2789 times
Again, one can see more light on the object, resulting in more contrast between object and background, and also shadows cast behind.

PL are very useful for direct lighting, however they cast very sharp shadows: that's why I think we'll also need area lights (which are much softer...) in the toolbox...
User avatar
furti
Posts: 344
Joined: Mon Nov 27, 2017 5:27 pm

Re: [Renderer Workbench] Lighting

Post by furti »

Nice. This looks pretty cool already.
howetuft wrote: Sat Dec 07, 2019 11:50 am PL are very useful for direct lighting, however they cast very sharp shadows: that's why I think we'll also need area lights (which are much softer...) in the toolbox...
There is the directional light in the Arch Texture workbench. This should be a good fit for architectural projects.
User avatar
adrianinsaval
Veteran
Posts: 5544
Joined: Thu Apr 05, 2018 5:15 pm

Re: [Renderer Workbench] Lighting

Post by adrianinsaval »

howetuft wrote: Sat Dec 07, 2019 11:50 am PovrayProject10jb6w0p_withPL.png
Sorry for the offtopic but, damn that's an impressive model, cool to see things like this done in FreeCAD
howetuft
Posts: 313
Joined: Tue Sep 10, 2019 8:16 pm

Re: [Renderer Workbench] Lighting

Post by howetuft »

furti wrote: Sat Dec 07, 2019 7:02 pm Nice. This looks pretty cool already.
Thank you!

furti wrote: Sat Dec 07, 2019 7:02 pm
There is the directional light in the Arch Texture workbench. This should be a good fit for architectural projects.
Sure! Directional lights could also be one of the lighting tools for rendering, they are very convenient to simulate sun. However, directional lights cast sharp shadows, like point lights. So, we'll also need area lights for soft shadows (for tri lighting, for instance).
adrianinsaval wrote: Sat Dec 07, 2019 9:28 pm
howetuft wrote: Sat Dec 07, 2019 11:50 am PovrayProject10jb6w0p_withPL.png
Sorry for the offtopic but, damn that's an impressive model, cool to see things like this done in FreeCAD
Thank you for your support! The author of the model is Yorik, I must insist :D ...
howetuft
Posts: 313
Joined: Tue Sep 10, 2019 8:16 pm

Re: [Renderer Workbench] Lighting

Post by howetuft »

I eventually found some time to add support for point lights to Luxcore renderer (PR is here: https://github.com/FreeCAD/FreeCAD-render/pull/20)!
Here is a simple scene (the same as previously used for POV):
ball.png
ball.png (59.71 KiB) Viewed 2552 times
A few comments:
- To be fully operational, this evolution requires that the PointLight has a RenderingPower property. It is in my pull request #34 to @Furti's Arch Texture (https://github.com/furti/FreeCAD-ArchTextures/pull/34), hope it will be accepted...
- I chose to introduce a new template with no predefined light, which I called 'luxrender_flat.lxs'. Other existing templates contain predefined powerful lighting, like sun or sky, that interfere with pointlights (no way to see a pointlight in full daylight :o ).
- Compared to POV, Lux rendering is notably darker (black background, dark shadow). However, Lux is right: in POV, the template adds an area light just behind the camera and a "skysphere" - very helpful, indeed, but a bit unfair... ;)
- A quite important point: lxs format, the format used by our Lux templates and our Lux exporter, is outdated. Luxcore now uses a new specification called SDL (https://wiki.luxcorerender.org/LuxCore_ ... anual_v2.3). No specification for lxs can be found any more, so it is kind of hard to develop new functionalities (for my code; I made some reverse engineering with luxcoreui importer, here: https://github.com/LuxCoreRender/LuxCor ... /luxparser, but it is quite time-consuming). I think we should add to our roadmap to port our exporter to SDL.
howetuft
Posts: 313
Joined: Tue Sep 10, 2019 8:16 pm

Re: [Renderer Workbench] Lighting

Post by howetuft »

Studying again POV standard template, I finally added a skysphere to luxrender_standard.lxs template (called a 'constantinfinite' in SDL).

Then I was eventually able to render with Luxcore the 2 scenes I previously built for POV-Ray:
ball2.png
ball2.png (63.8 KiB) Viewed 2508 times
lux_building.png
lux_building.png (309.9 KiB) Viewed 2508 times
howetuft
Posts: 313
Joined: Tue Sep 10, 2019 8:16 pm

Re: [Renderer Workbench] Lighting

Post by howetuft »

I've completed support for Point Light in Cycles exporter. Here are my 2 scenes rendered with Cycles:

CyclesProject9s6dauj_.png
CyclesProject9s6dauj_.png (70.74 KiB) Viewed 2468 times
CyclesProjectu87azg7i.png
CyclesProjectu87azg7i.png (509.6 KiB) Viewed 2468 times
Interestingly, there is no automatic smoothing in Cycles, so we can see small triangular sub-faces on the sphere... As a counterpart, details are more precisely rendered with Cycles than with Luxcore, to my point of view.
Electroguy
Posts: 2
Joined: Thu Jul 23, 2020 12:49 am

Re: [Renderer Workbench] Lighting

Post by Electroguy »

I have evaluated the Renderer Workbench after first checked out Raytracing Workbench.
The rendered I tested was POW-Ray 3.7.0 and LuxCoreRender v2.4rc1 (had to update NVIDA driver to get it working).
Everything seems to work good in both Renderer Workbench and Raytracing Workbench.
I have also tried to apply textures in Arch Texture Workbench. The color from the material seems to be exported but not the texture itself.
Also noted that both Arch Texture Workbench and Renderer Workbench have lamps etc. but they seem not related.

I have experimented with the deviation settings in Raytracing Workbench and Deviation 0.01 (compared to 0.05) result in a much larger export files.
This settings seem to have no function in Renderer Workbench and the outputs files always become very small with jagged surfaces at the rendering scene.

Deviation settings
Deviation settings
Deviation setting.png (21.54 KiB) Viewed 2200 times
Smooth surfaces (larger files from Raytracing Workbench)
Smooth surfaces (larger files from Raytracing Workbench)
Gauge - Smoth.png (580.17 KiB) Viewed 2200 times
Jagged surfaces (from Renderer Workbench)
Jagged surfaces (from Renderer Workbench)
Gauge - Jagged.png (426.24 KiB) Viewed 2200 times
Post Reply