shadows in the freecad viewport

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
OficineRobotica
Posts: 186
Joined: Thu Feb 21, 2019 8:17 am

Re: shadows in the freecad viewport

Postby OficineRobotica » Wed May 27, 2020 7:02 am

Can I propose changing the shading mode name from "shadow" to "real time shadow" for PR purposes? :D Although it could be a bit long to fit in the drop down menu.

I can already imagine someone with coding knowledge developing an addon to simulate the passage of the sun for architectural models.
User avatar
pablogil
Posts: 834
Joined: Wed Nov 26, 2014 3:19 pm
Location: Badajoz (Spain)
Contact:

Re: shadows in the freecad viewport

Postby pablogil » Wed May 27, 2020 7:39 am

OficineRobotica wrote:
Wed May 27, 2020 7:02 am
I can already imagine someone with coding knowledge developing an addon to simulate the passage of the sun for architectural models.
That could be really easy to implement and so cool for BIM designers!
Dark and Light stylesheets v2.0 to theme your FreeCAD UI, more information here
User avatar
markko martin
Posts: 29
Joined: Tue Aug 09, 2016 5:51 pm
Location: Italy

Re: shadows in the freecad viewport

Postby markko martin » Wed May 27, 2020 9:06 am

OficineRobotica wrote:
Wed May 27, 2020 7:02 am
...I can already imagine someone with coding knowledge developing an addon to simulate the passage of the sun for architectural models.
I also hope that we will be able to simulate the sun soon.

If pysolar is installed on your system, Arch Sites can display a solar diagram.
https://wiki.freecadweb.org/Arch_Site
Loris
freecad-heini-1
Posts: 7029
Joined: Tue Jan 07, 2014 11:10 am
Contact:

Re: shadows in the freecad viewport

Postby freecad-heini-1 » Wed May 27, 2020 10:31 am

OficineRobotica wrote:
Wed May 27, 2020 6:20 am
realthunder wrote:
Tue May 26, 2020 10:54 pm
Image updated.
Image
https://forum.freecadweb.org/viewtopic. ... 58#p184358
Image

Would you be so kind to put hammax dolphin in the pool?
Just for fun.

Thanks a lot and best regards
Wilfried
paullee
Posts: 2380
Joined: Wed May 04, 2016 3:58 pm

Re: shadows in the freecad viewport

Postby paullee » Wed May 27, 2020 6:29 pm

OficineRobotica wrote:
Wed May 27, 2020 7:02 am
I can already imagine someone with coding knowledge developing an addon to simulate the passage of the sun for architectural models.
+1

:)
User avatar
Kunda1
Posts: 7473
Joined: Thu Jan 05, 2017 9:03 pm

Re: shadows in the freecad viewport

Postby Kunda1 » Wed May 27, 2020 7:13 pm

paullee wrote:
Wed May 27, 2020 6:29 pm
OficineRobotica wrote:
Wed May 27, 2020 7:02 am
I can already imagine someone with coding knowledge developing an addon to simulate the passage of the sun for architectural models.
+1
Like these threads ?
https://forum.freecadweb.org/viewtopic.php?f=23&t=36162
https://forum.freecadweb.org/viewtopic.php?f=23&t=18587
https://forum.freecadweb.org/viewtopic.php?t=9663
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
paullee
Posts: 2380
Joined: Wed May 04, 2016 3:58 pm

Re: shadows in the freecad viewport

Postby paullee » Thu May 28, 2020 5:29 am

Kunda1 wrote:
Wed May 27, 2020 7:13 pm
paullee wrote:
Wed May 27, 2020 6:29 pm
OficineRobotica wrote:
Wed May 27, 2020 7:02 am
I can already imagine someone with coding knowledge developing an addon to simulate the passage of the sun for architectural models.
+1
Like these threads ?
https://forum.freecadweb.org/viewtopic.php?f=23&t=36162
https://forum.freecadweb.org/viewtopic.php?f=23&t=18587
https://forum.freecadweb.org/viewtopic.php?t=9663
Yes, perfect for building industry :D
OficineRobotica
Posts: 186
Joined: Thu Feb 21, 2019 8:17 am

Re: shadows in the freecad viewport

Postby OficineRobotica » Thu May 28, 2020 6:01 am

freecad-heini-1 wrote:
Wed May 27, 2020 10:31 am
Would you be so kind to put hammax dolphin in the pool?
Just for fun.

Thanks a lot and best regards
Wilfried
Here you go.
https://forum.freecadweb.org/viewtopic. ... 38#p403138
realthunder
Posts: 1580
Joined: Tue Jan 03, 2017 10:55 am

Re: shadows in the freecad viewport

Postby realthunder » Mon Jun 08, 2020 1:59 pm

Image updated. New support for smooth border and soft shadow rendering.

New property 'Smooth Border' to for border smoothing. This is mostly used in directional light.

'Spread Size' is to control the shadow spread size, i.e. the penumbra size. This makes more sense in spot light. The value does not directly determine the spread size. It also depending on the model size, so you may need to tune it for each model. 'Spread Sample Size' specifies the internal sample size used for filtering for blurring. 0 is the cheapest which kind of cheated using dithering. So you may find some noise in the penumbra. size 1 usually performs worth than 0, but gets better with 2 and above. However, increasing sample size will have an obvious impact on rendering performance.

One way to improve performance is to decrease 'Precision'. When 'Precision' is 1, Coin3D uses a texture size of 2048x2048 to store the shadow map. If you want soft shadow, then you should reduce the the shadow map size, because smaller image is easy to blur obviously. the texture size used is Precision * 2048 rounding to power of 2. So, 0.1 corresponds to 256x256, or 0.2 for 512x512, or 0.5 for 1024x1024.

For more technical references, you can consult the commit message here. Note that the 'smoothBorder' attribute mentioned there is for Coin3d internal use. I have expanded it into three FreeCAD properties for easy use.
Screenshot from 2020-06-08 21-14-05.png
Screenshot from 2020-06-08 21-14-05.png (154.84 KiB) Viewed 348 times
Try Assembly3 (latest version 0.11) along 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
paullee
Posts: 2380
Joined: Wed May 04, 2016 3:58 pm

Re: shadows in the freecad viewport

Postby paullee » Mon Jun 08, 2020 5:14 pm

Downloaded and tested, awesome :D

FreeCAD-asm3-Conda-Py3-Qt5-20200604-glibc2.12-x86_64.AppImage
on
Fedora 31

Some preliminary findings -
  1. No Shadow when it is Not Spot Light
  2. Seems the building elements are not casting / receiving shadow ?
  3. Seems only the ground plane is receiving shadow ?
Model

Additional Module may be required for Recompute

Screenshot from 2020-06-09 00-58-00.png
Screenshot from 2020-06-09 00-58-00.png (363.17 KiB) Viewed 283 times
OS: Fedora 31 (Workstation Edition) (GNOME/gnome)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.21300 +2326 (Git)
Build type: Release
Branch: LinkStage3
Hash: ee7b887a4768289d8bb6df644ce9d3fe18b68c94
Python version: 3.7.6
Qt version: 5.12.1
Coin version: 4.0.0
OCC version: 7.4.0
Locale: English/United States (en_US)