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!
freecad-heini-1
Veteran
Posts: 7788
Joined: Tue Jan 07, 2014 11:10 am
Contact:

Re: shadows in the freecad viewport

Post by freecad-heini-1 »

How to handle the *.iv file from yorik in his first post?
User avatar
microelly2
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: shadows in the freecad viewport

Post by microelly2 »

freecad-heini-1 wrote: Sun Jan 07, 2018 11:51 am How to handle the *.iv file from yorik in his first post?
You can open it Menu File -> open ...
but it does not work for me,
there is no ShadowGroup support in the pivy so the file does not have an effekt.
I will look how to get this ShadowGroup running

here is another iv file with a bit more action

Code: Select all

#Inventor V2.1 ascii

  # to get some lighting when headlight is turned off in the viewer
  DirectionalLight { direction 0 0 -1 intensity 0.2 }
  ShadowGroup {
    quality 1 # to get per pixel lighting
   # ShadowStyle { style NO_SHADOWING }
    SpotLight {
      location -8 -8 8.0
      direction 1 1 -1
      cutOffAngle 0.35
      dropOffRate 0.7
    }
    ShadowStyle { style SHADOWED }
    Separator {
      Complexity { value 1.0 }
      Material { diffuseColor 1 1 0 specularColor 1 1 1 shininess 0.9 }
      Shuttle { translation0 -3 1 0 translation1 3 -5 0 speed 0.25 on TRUE }
      Translation { translation -5 0 2 }
      Sphere { radius 2.0 }
    }
    Separator {
      Material { diffuseColor 1 0 0 specularColor 1 1 1 shininess 0.9 }
      Shuttle { translation0 0 -5 0 translation1 0 5 0 speed 0.15 on TRUE }
      Translation { translation 0 0 3 }
      Cube { depth 1.8 }
    }
    Separator {
      Material { diffuseColor 0 1 0 specularColor 1 1 1 shininess 0.9 }
      Shuttle { translation0 -5 0 0 translation1 5 0 0 speed 0.3 on TRUE }
      Translation { translation 0 0 -3 }
      Cube { }
    }
    ShadowStyle { style SHADOWED }
    Coordinate3 { point [ -10 -10 -3, 10 -10 -3, 10 10 -3, -10 10 -3 ] }
    Material { specularColor 1 1 1 shininess 0.9 }
    Complexity { textureQuality 0.1 }
    Texture2 { image 2 2 3 0xffffff 0x225588 0x225588 0xffffff }
    Texture2Transform { scaleFactor 4 4 }
    FaceSet { numVertices 4 }
  }

freecad-heini-1
Veteran
Posts: 7788
Joined: Tue Jan 07, 2014 11:10 am
Contact:

Re: shadows in the freecad viewport

Post by freecad-heini-1 »

microelly2 wrote: Sun Jan 07, 2018 11:56 am
freecad-heini-1 wrote: Sun Jan 07, 2018 11:51 am How to handle the *.iv file from yorik in his first post?
You can open it Menu File -> open ...
but it does not work for me,
there is no ShadowGroup support in the pivy so the file does not have an effekt.
I will look how to get this ShadowGroup running

here is another iv file with a bit more action

Code: Select all

#Inventor V2.1 ascii

  # to get some lighting when headlight is turned off in the viewer
  DirectionalLight { direction 0 0 -1 intensity 0.2 }
  ShadowGroup {
    quality 1 # to get per pixel lighting
   # ShadowStyle { style NO_SHADOWING }
    SpotLight {
      location -8 -8 8.0
      direction 1 1 -1
      cutOffAngle 0.35
      dropOffRate 0.7
    }
    ShadowStyle { style SHADOWED }
    Separator {
      Complexity { value 1.0 }
      Material { diffuseColor 1 1 0 specularColor 1 1 1 shininess 0.9 }
      Shuttle { translation0 -3 1 0 translation1 3 -5 0 speed 0.25 on TRUE }
      Translation { translation -5 0 2 }
      Sphere { radius 2.0 }
    }
    Separator {
      Material { diffuseColor 1 0 0 specularColor 1 1 1 shininess 0.9 }
      Shuttle { translation0 0 -5 0 translation1 0 5 0 speed 0.15 on TRUE }
      Translation { translation 0 0 3 }
      Cube { depth 1.8 }
    }
    Separator {
      Material { diffuseColor 0 1 0 specularColor 1 1 1 shininess 0.9 }
      Shuttle { translation0 -5 0 0 translation1 5 0 0 speed 0.3 on TRUE }
      Translation { translation 0 0 -3 }
      Cube { }
    }
    ShadowStyle { style SHADOWED }
    Coordinate3 { point [ -10 -10 -3, 10 -10 -3, 10 10 -3, -10 10 -3 ] }
    Material { specularColor 1 1 1 shininess 0.9 }
    Complexity { textureQuality 0.1 }
    Texture2 { image 2 2 3 0xffffff 0x225588 0x225588 0xffffff }
    Texture2Transform { scaleFactor 4 4 }
    FaceSet { numVertices 4 }
  }

No success. I copy your code into a file and named it thomas.iv
If I open it, there is nothing, but if I open the *.iv from yorik there is a plane and a light reflecting on it.
User avatar
microelly2
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: shadows in the freecad viewport

Post by microelly2 »

here as a file
shadow.iv
(1.43 KiB) Downloaded 174 times
yoriks files shows a plane and a reflexion of course but the shadow does not work.
User avatar
yorik
Founder
Posts: 13640
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: shadows in the freecad viewport

Post by yorik »

Note that loading the iv file from the FreeCAD File menu doesn't make use of pivy.

My computer has two GPUs, the one that is bundled inside the i7 processor and an nvidia GPU. If I run FreeCAD on the i7 GPU (using mesa drivers on linux), the shadows don't appear. If I use the nvidia GPU instead (with the proprietary driver), then the shadows are there. So the problem is probably between Coin and the OpenGL support that the driver offers...
User avatar
microelly2
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: shadows in the freecad viewport

Post by microelly2 »

yorik wrote: Sun Jan 07, 2018 2:49 pm So the problem is probably between Coin and the OpenGL support that the driver offers...
hello Yorik, which coin do you use?



OS: Ubuntu 14.04.5 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.12920 (Git)
Build type: None
Branch: master
Hash: 8faa9f38bb70a598afc2bc39ea1645d416ab057e
Python version: 2.7.6
Qt version: 4.8.6
Coin version: 4.0.0a
OCC version: 7.1.0
Locale: German/Germany (de_DE)

>>>
>>> from pivy import coin
>>> coin
<module 'pivy.coin' from '/usr/lib/python2.7/dist-packages/pivy/coin.pyc'>
>>>
>>> coin.SoSpotLight
<class 'pivy.coin.SoSpotLight'>
>>> coin.SoShadowStyle
Traceback (most recent call last):
File "<input>", line 1, in <module>
AttributeError: 'module' object has no attribute 'SoShadowStyle'
>>> coin.COIN_MAJOR_VERSION
4
>>> coin.COIN_MICRO_VERSION
0
>>> coin.COIN_MINOR_VERSION
0
User avatar
yorik
Founder
Posts: 13640
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: shadows in the freecad viewport

Post by yorik »

Same version...

OS: Debian GNU/Linux testing (buster)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.12930 (Git)
Build type: Unknown
Branch: master
Hash: 50c280fdb69f03c79b35a5202972c2f74028a627
Python version: 2.7.14+
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.1.0.beta
Locale: English/UnitedKingdom (en_GB)
User avatar
microelly2
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: shadows in the freecad viewport

Post by microelly2 »

So I really need other hardware to get shadows.
For the moment this is my way to get light and darkness
phpBB [video]

there are some light nodes and lets see what other open inventor effects can be put into this tool. :roll:
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: shadows in the freecad viewport

Post by looo »

SoShadowStyle
is that available in coin? maybe we can add some bindings with pivy.
User avatar
microelly2
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: shadows in the freecad viewport

Post by microelly2 »

looo wrote: Mon Jan 08, 2018 11:02 pm
SoShadowStyle
is that available in coin? maybe we can add some bindings with pivy.
what source base of coin we use
here it is
https://github.com/Alexpux/Coin3D/blob/ ... wStyle.cpp

but to get shadows special hardware is required.

I will not devolop something for special hardware becausemostusershave default computers.
Post Reply