shadows in the freecad viewport

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
User avatar
apeltauer
Posts: 212
Joined: Fri Aug 11, 2017 2:19 pm

Re: shadows in the freecad viewport

Postby apeltauer » Sat Aug 10, 2019 8:22 pm

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
Site Admin
Posts: 14999
Joined: Thu Feb 19, 2009 10:32 am

Re: shadows in the freecad viewport

Postby wmayer » 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
User avatar
apeltauer
Posts: 212
Joined: Fri Aug 11, 2017 2:19 pm

Re: shadows in the freecad viewport

Postby apeltauer » Sun Aug 11, 2019 11:16 am

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
Site Admin
Posts: 14999
Joined: Thu Feb 19, 2009 10:32 am

Re: shadows in the freecad viewport

Postby wmayer » Sun Aug 11, 2019 12:22 pm

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: 212
Joined: Fri Aug 11, 2017 2:19 pm

Re: shadows in the freecad viewport

Postby apeltauer » 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
wmayer
Site Admin
Posts: 14999
Joined: Thu Feb 19, 2009 10:32 am

Re: shadows in the freecad viewport

Postby wmayer » Sun Aug 11, 2019 1:21 pm

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.