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!
Post Reply
User avatar
apeltauer
Posts: 399
Joined: Fri Aug 11, 2017 2:19 pm

Re: shadows in the freecad viewport

Post by apeltauer »

wmayer wrote: Wed Aug 07, 2019 8:27 am In the FreeCAD core system we have the command to render in different draw styles (no shading, wireframe, ...) and we could add it there.

However, at the moment the shadow function is a bit unrealistic because when you move or rotate the model then the shadow follows which means that the light source moves, too. However, the light source should be fix.

I guess this happens because the shadow group appears after the camera node in the scene graph and not before. This must be further checked...
My question is off topic but maybe it can be answered with a yes or no.
Can we get the shadow shape somehow in the scene graph and can convert this shadow to an occ shape? Just thinking about a outer silhouette of a part...
wmayer
Founder
Posts: 20309
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: shadows in the freecad viewport

Post by wmayer »

Can we get the shadow shape somehow in the scene graph and can convert this shadow to an occ shape?
No, you can't.
Just thinking about a outer silhouette of a part...
If you need this then have a look at Part.Shape.reflectLines
User avatar
apeltauer
Posts: 399
Joined: Fri Aug 11, 2017 2:19 pm

Re: shadows in the freecad viewport

Post by apeltauer »

wmayer wrote: Sun Aug 11, 2019 10:16 am
Can we get the shadow shape somehow in the scene graph and can convert this shadow to an occ shape?
No, you can't.
Just thinking about a outer silhouette of a part...
If you need this then have a look at Part.Shape.reflectLines
Short answer to this and then i am out... :)
All Hidden Line Removel algorithm (which the reflection lines are also belonging to) do not work proper (as fare is was testing them. in the occ bug tracker and feature list i found a topic where they want to improve the hlr algorithm with help of the open gl capability (stancil buffer?!?!) ).
I already tested the reflection lines according to the topic in the german subforum (https://forum.freecadweb.org/viewtopic. ... 0&start=60) but it does not have a proper result, like it is described in the topic
wmayer
Founder
Posts: 20309
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: shadows in the freecad viewport

Post by wmayer »

All Hidden Line Removel algorithm (which the reflection lines are also belonging to) do not work proper (as fare is was testing them.
Yes, it's known that they fail in many cases. Especially about the reflect-lines algorithm my finding was that it fails on hard (i.e. C0-tangent) edges where it's impossible to determine a tangent.
in the occ bug tracker and feature list i found a topic where they want to improve the hlr algorithm with help of the open gl capability (stancil buffer?!?!) )
In the past I also was searching how e.g. Blender displays the orange silhouette around objects and found that it's done by the stencil buffer. But I wonder how exactly OCC wants to use this information to improve the HLR algorithms. Can you post a link to the bug tracker entry, please?
User avatar
apeltauer
Posts: 399
Joined: Fri Aug 11, 2017 2:19 pm

Re: shadows in the freecad viewport

Post by apeltauer »

wmayer wrote: Sun Aug 11, 2019 12:22 pm In the past I also was searching how e.g. Blender displays the orange silhouette around objects and found that it's done by the stencil buffer. But I wonder how exactly OCC wants to use this information to improve the HLR algorithms. Can you post a link to the bug tracker entry, please?
https://tracker.dev.opencascade.org/view.php?id=24437
wmayer
Founder
Posts: 20309
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: shadows in the freecad viewport

Post by wmayer »

apeltauer wrote: Sun Aug 11, 2019 1:04 pm
wmayer wrote: Sun Aug 11, 2019 12:22 pm In the past I also was searching how e.g. Blender displays the orange silhouette around objects and found that it's done by the stencil buffer. But I wonder how exactly OCC wants to use this information to improve the HLR algorithms. Can you post a link to the bug tracker entry, please?
https://tracker.dev.opencascade.org/view.php?id=24437
As far as I understand the feature request then in the past OCCT used its geometric HLR algorithms to handle the rendering of an AIS_Shape which is slow because everything happens on the CPU and error-prone.
Currently, OCCT runs rather heavy geometrical computations on CPU in order to compute hidden-line representation of an AIS_Shape object. And it works with bugs on some specific kinds of input shapes.
So, the plan is NOT to use OpenGL techniques to improve the geometric HLR algorithms but to avoid to use the latter and do everything directly in OpenGL instead.
realthunder
Veteran
Posts: 2190
Joined: Tue Jan 03, 2017 10:55 am

Re: shadows in the freecad viewport

Post by realthunder »

I was doing some work on the Hidden Line draw style, and thought about adding a 'Shadow' style that I saw in other CAD. So I searched around and found this thread and get some head start.

Here is my implementation, you can try it with my fork at here. The 'Shadow' style can be customized through document property. In other word, the configuration is customizable and saved to each document. By default the 'Shadow' draw style comes with a ground at the Z bottom of the scene bounding box. You can turn off the ground, move it, change color, etc. You can choose lighting type, color, direction, intensity, and many more.

Image
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
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: shadows in the freecad viewport

Post by Kunda1 »

:o :shock:
Uhmm...subscribing to this thread for sure!
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
carlopav
Veteran
Posts: 2062
Joined: Mon Dec 31, 2018 1:49 pm
Location: Venice, Italy

Re: shadows in the freecad viewport

Post by carlopav »

WOW this is a game changer for architectural design!!!

BTW, I tried it, but it produces the following error:

Code: Select all

Illegal storage access...
if I activate it and then try to manipulate somthing in the 3dview
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 »

carlopav wrote: Mon May 04, 2020 2:29 pm BTW, I tried it, but it produces the following error:

Code: Select all

Illegal storage access...
if I activate it and then try to manipulate somthing in the 3dview
You are using Windows right? Did you see the shadow? On my Windows machine, I see blank when using SoShadowDirectionalLight or SoShadowSpotLight. Changing to SoDirectionalLight shows the object and ground but no shadow. Changing to SoSpotLight shows the shadow, but the whole scene disappears as long as I move my mouse over any object, and will reappear if I rotate the scene. There is no problem on my Linux machine.

Can you please open this test file with FC and check if there is anything wrong.
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
Post Reply