shadows in the freecad viewport

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!
realthunder
Veteran
Posts: 2190
Joined: Tue Jan 03, 2017 10:55 am

Re: shadows in the freecad viewport

Post by realthunder »

pablogil wrote: Mon May 25, 2020 7:38 am I think I have a new clue about this issue: the shadow is behaving as a normal "shaded face", it means it will be shaded depending on the position of light and view. The casted shadow, at least when displayed with the ground disabled, should behave as a "shadeless face". Could this be done?

Cheers
Well, just think of the ground as a normal face of any other object. When you change the camera position, the shading of the face changes. When the ground shade is lightened, so is the shadow on it. The reason you see the shadow 'disappear' when you have a transparent ground is because I clamped the shadow color to the ground diffuse color, otherwise you'll see a shadow that is lighter than the background, which would be very odd. So, if you do not want the shadow 'disappear' when using a transparent ground, set the ground color to be darker than the background.
Try Assembly3 with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
realthunder
Veteran
Posts: 2190
Joined: Tue Jan 03, 2017 10:55 am

Re: shadows in the freecad viewport

Post by realthunder »

OficineRobotica wrote: Mon May 25, 2020 10:12 am At least on that model I get a big performance difference in frame rate between regular and spotlight. Usually the spotlight is 10x faster than regular light. I get around 3 to 10 fps when navigating the 3d viewport when using the regular light whereas I get a minimum of 30fps with the spotlight on the same scene and same machine . For my usual modeling(mechanical) I prefer the spotlight but that doesn't play really well with architectural models where the regular light makes more sense.
That's unexpected. I expect the opposite. There's probably something wrong with the caching. I'll look into it when I got time.

Also, if you have the time, can we get a better explanation of the shadow properties like epsilon, precision, quality, and spotlight cutoff angle, spotlight dropoff rate. With some of these properties I get more of an on/off effect when modifieng the values and I can't really understand they'r use.
Please check the 'Public attribute' of the Coin3D SoShadowGroup node. Some of the attribute has no effect, and some does not seem to behave as documented. I am exposing those for experimental purpose as well.
Try Assembly3 with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
User avatar
pablogil
Posts: 882
Joined: Wed Nov 26, 2014 3:19 pm
Location: Badajoz (Spain)
Contact:

Re: shadows in the freecad viewport

Post by pablogil »

realthunder wrote: Mon May 25, 2020 2:02 pm Well, just think of the ground as a normal face of any other object. When you change the camera position, the shading of the face changes. When the ground shade is lightened, so is the shadow on it. The reason you see the shadow 'disappear' when you have a transparent ground is because I clamped the shadow color to the ground diffuse color, otherwise you'll see a shadow that is lighter than the background, which would be very odd. So, if you do not want the shadow 'disappear' when using a transparent ground, set the ground color to be darker than the background.
Yes, that is what I did and it worked but, it's still a little bit annoing that the shadow changes its "lightness" depending on the user view... Couldn't you set this face as shadeless?

Thanks
Dark and Light stylesheets v2.0 to theme your FreeCAD UI, more information here
carlopav
Veteran
Posts: 2062
Joined: Mon Dec 31, 2018 1:49 pm
Location: Venice, Italy

Re: shadows in the freecad viewport

Post by carlopav »

Tested with:

Code: Select all

OS: Windows 10 (10.0)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.20886 +2287 (Git)
Build type: Release
Branch: LinkStage3
Hash: 5f7898eae20e4e8ef3e6190ad8b354e23bbf66e7
Python version: 3.6.8
Qt version: 5.12.1
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: Italian/Italy (it_IT)
Graphics card GTX 1070
Works great... the effect of having both shadows and bump map is just awesome!
I noticed that shadows are not shown when:
- adding some standard Part objects (a cube)
- switch to Draft WB
- enable the Draft_Grid.
- shadow disappears.

Perhaps it's a good chance to think about a standard Gui::Grid that every workbench share... (ref https://forum.freecadweb.org/viewtopic.php?f=22&t=22296)

Edit: maybe i found it, it should be about the scale: the grid is so big compared to std Part objects! if I add a bigger object the shadow is displayed perfectly also with the grid! sorry for the noise.
follow my experiments on BIM modelling for architecture design
realthunder
Veteran
Posts: 2190
Joined: Tue Jan 03, 2017 10:55 am

Re: shadows in the freecad viewport

Post by realthunder »

Can you guys try the spot light with 'DropOffRate' and 'CutOffAngle' settings? Any effect? I managed to make them work on my computer but requires yet another patch to Coin3D. It seems to be crippled by some graphics driver bug in updating shader predefined variables. Not sure if it is specific to my graphics driver. I am using ubuntu with Intel integrated graphics.
Try Assembly3 with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
carlopav
Veteran
Posts: 2062
Joined: Mon Dec 31, 2018 1:49 pm
Location: Venice, Italy

Re: shadows in the freecad viewport

Post by carlopav »

realthunder wrote: Tue May 26, 2020 10:05 am Can you guys try the spot light with 'DropOffRate' and 'CutOffAngle' settings?
Works fine here with the system of the above post.
xgCxerHKiL.gif
xgCxerHKiL.gif (162.92 KiB) Viewed 1846 times
follow my experiments on BIM modelling for architecture design
User avatar
pablogil
Posts: 882
Joined: Wed Nov 26, 2014 3:19 pm
Location: Badajoz (Spain)
Contact:

Re: shadows in the freecad viewport

Post by pablogil »

realthunder wrote: Tue May 26, 2020 10:05 am Can you guys try the spot light with 'DropOffRate' and 'CutOffAngle' settings? Any effect? I managed to make them work on my computer but requires yet another patch to Coin3D. It seems to be crippled by some graphics driver bug in updating shader predefined variables. Not sure if it is specific to my graphics driver. I am using ubuntu with Intel integrated graphics.
It seems to work properly on the objects but it makes something strange in the shadow (when "ground transparency" is set to 1):
shadow.png
shadow.png (200.8 KiB) Viewed 1835 times
Dark and Light stylesheets v2.0 to theme your FreeCAD UI, more information here
realthunder
Veteran
Posts: 2190
Joined: Tue Jan 03, 2017 10:55 am

Re: shadows in the freecad viewport

Post by realthunder »

Image updated.

Fixed a few spot light settings. The cut off angle previously uses radian instead of degree. Drop off rate can now be negative, which will make the spotlight a special non attenuating 'directional spotlight'. Note that the drop off rate attenuates the light intensity with exponential rate. It appears that the initial drop is much faster comparing to later. I have changed the spin box step to 0.01.

OficineRobotica wrote: Mon May 25, 2020 10:12 am At least on that model I get a big performance difference in frame rate between regular and spotlight.
Directional light now should have the same performance as spot light. This is another coin3D problem.

pablogil wrote: Mon May 25, 2020 7:38 am I think I have a new clue about this issue: the shadow is behaving as a normal "shaded face", it means it will be shaded depending on the position of light and view. The casted shadow, at least when displayed with the ground disabled, should behave as a "shadeless face". Could this be done?
I have added a new setting 'GroundShading' for that, and can be configured in preference dialog. When disabled, the shadow will have no shading. You can use the ground color to change the shadow color.
Try Assembly3 with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
User avatar
OficineRobotica
Posts: 433
Joined: Thu Feb 21, 2019 8:17 am
Contact:

Re: shadows in the freecad viewport

Post by OficineRobotica »

realthunder wrote: Tue May 26, 2020 10:54 pm Image updated.

Fixed a few spot light settings. The cut off angle previously uses radian instead of degree. Drop off rate can now be negative, which will make the spotlight a special non attenuating 'directional spotlight'. Note that the drop off rate attenuates the light intensity with exponential rate. It appears that the initial drop is much faster comparing to later. I have changed the spin box step to 0.01.
I haven't realized previously the power of this shading mode when using freecad. When working with assemblies or other complex parts it gives a REAL visual advantage enabling me to concentrate on the workflow instead of squinting at the screen, trying to figure out where one component meets another. This is why , in my opinion, the drop shadow mode should be up high as importance for the merger in freecad trunk and a great value addition. I also think it could be a excellent tool as pr/publicity for spreading freecad in to the wild. Looking back at the history, Blender and Krita have exploded in popularity after similar visual changes that generated cool screenshots which in turn got people interested in giving a real try at using the application.


One simply got to love the shadows in the pool.
barcelonaPavilion_poolSahdow.jpeg
barcelonaPavilion_poolSahdow.jpeg (394.96 KiB) Viewed 1746 times




Directional light now should have the same performance as spot light. This is another coin3D problem.
Indeed I get the same performance now on my hardware.
Also, I cant put my finger on what it is, but the shading of the models with the directional light now is just......better.
better_shading.jpeg
better_shading.jpeg (286.71 KiB) Viewed 1740 times





I have added a new setting 'GroundShading' for that, and can be configured in preference dialog. When disabled, the shadow will have no shading. You can use the ground color to change the shadow color.
I find this mode to be more realistic in some cases and less distracting while having at the same time the clue of the shadow underneath the model. Thank you.
Check out my Youtube channel at: https://www.youtube.com/@OficineRobotica
carlopav
Veteran
Posts: 2062
Joined: Mon Dec 31, 2018 1:49 pm
Location: Venice, Italy

Re: shadows in the freecad viewport

Post by carlopav »

indeed i'm already in love with the shadow in the pool! :o
follow my experiments on BIM modelling for architecture design
Post Reply