Materials, physical, optical, for ray tracer and simulation

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
arust
Posts: 6
Joined: Wed Feb 04, 2015 9:34 am

Materials, physical, optical, for ray tracer and simulation

Post by arust »

Dear all,

Advanced spectral renderers (like LuxRender, many commercial renderers, and to some extend even Povray) do not use RGB internally, but physical spectral reflection, refraction, emission properties, given for example as color temperature, spectrum texture or look-up table[1], lamp-vendor-provided IES file[2], and physical refraction and reflection indices.[3] Databases like the Refractive Index Database provide a great number of measured material spectra for optical, microwave and IR simulation to the Open-Source community, suitable for rendering and physical simulation.[4]

As FreeCAD does not care so much about fancy color display, but proper physical modeling of parts, to me (the uninitiated outsider) it looks like "the right thing" to have some facility to enter not only display RGBA "appearance", but to store physical optical properties – for rendering, and simulation purposes? Exporters to the raytracer or FEM tool can use these properties instead of RGB, if provided by the user.

In summary, it seems desirable to be able to specify physical optical properties, which are supported by LuxRender, Povray and other advanced rendering and simulation engines, in addition to the currently existing facility for plain RGBA color and shininess, used mostly for fast and low-quality real-time preview rendering.

This is admittedly a huge topic. Maybe it makes sense to focus on the low-hanging fruit of great visual ray tracing materials first, to pipe-clean the process of creating a great material database containing not only optical, but also mechanical material properties? What is the prevailing general opinion on this subject?

What can be done to contribute, help and support such development?

NB. this has also been submitted as feature request to the bug tracker (issue #1942). Not sure if this is the right place to start a discussion.
____

[1] http://www.luxrender.net/wiki/LuxRender ... s_Spectrum
[2] http://www.luxrender.net/wiki/LuxRender ... g#IES_data
[3] http://www.luxrender.net/wiki/Scene_fil ... v#Material
[4] http://refractiveindex.info/download.php
Last edited by NormandC on Wed Feb 04, 2015 5:46 pm, edited 1 time in total.
Reason: Edited bug tracker issue number to add link.
User avatar
sgrogan
Veteran
Posts: 6499
Joined: Wed Oct 22, 2014 5:02 pm

Re: Materials, physical, optical, for ray tracer and simulat

Post by sgrogan »

Hello arust and Welcome to FreeCAD. :D

There is this as part of the development road map.
http://www.freecadweb.org/wiki/index.ph ... data_model
"fight the good fight"
mrlukeparry
Posts: 655
Joined: Fri Jul 22, 2011 8:37 pm
Contact:

Re: Materials, physical, optical, for ray tracer and simulat

Post by mrlukeparry »

The idea I had years ago was hooking onto some kind of material properties framework and selecting a XML definitons for each specific ray tracer like a template. This is buried somewhere in my repo as I haven't looked at it for a long while.

One thing that hasn't been answered is the idea of real-time integrated ray-tracer even if the performance requirements restrict its adoption to only a select group of users. OpenCascade recently added this to their own visualisation framework, I don't know if anyone has looked directly at the source of this and seeing if it could be adapted.

Eventually as larger 3D printed components become more prevalent, the increased internal/external complexity of designs will probably mean we cannot rely on the current methods.
arust
Posts: 6
Joined: Wed Feb 04, 2015 9:34 am

Re: Materials, physical, optical, for ray tracer and simulat

Post by arust »

This is a very interesting consideration! For internal higher-quality preview the Real-time-Raytracing is definitely a very interesting option, especially since it claims to be competitive, or even faster, compared to the "default" OpenGL renderer – at least in some important cases (depending on model and GPU, huge and very complex models seem faster on ray tracer).

Digging in the OCCT GIT repo, I realized that OpenCascade examples even set a "material" property, used by the ray tracer (and, since it is merely a symbolic name, surely usable by FEM preprocessor tools!):

Code: Select all

  ## http://git.dev.opencascade.org/gitweb/?p=occt.git;a=blob;f=tests/v3d/raytrace/refraction;h=6ded478ed9be64528e4786ea5df4b565f0a4637c;hb=dc9ef964d20d338635a081f2e2f883b3803a161f
  [...]
  49 vsetmaterial B1 water
  50 vsetmaterial B2 glass
  51 vsetmaterial B3 diamond
  52 
  53 vsetmaterial wall1 stone
  54 vsetmaterial wall2 stone
  55 vsetmaterial wall3 stone
  56 
  57 vsetcolor wall1 red
  58 vsetcolor wall2 green
  59 
  60 vsettransparency S1 0.8
  61 vsettransparency S2 0.8
  62 vsettransparency S3 0.8
  63 
  64 vsettransparency B1 0.8
  65 vsettransparency B2 0.8
  66 vsettransparency B3 0.8
  [...]
How to set and access this "vsetmaterial" field (or the matching field in the underlying representation in the scene graph)?

Assuming this is possible, the external ray tracer or FEM tool/preprocessor can then use this material name to look up physical properties in a user-provided or built-in material database. This seems quite easy to implement, if I get some directions for "proper" implementation, I might even volunteer for the LuxRender exporter, ...

Additionally, this seems to be consistent with the built-in OpenCascade ray tracer, so that integration is facilitated, maybe as simple as "optionally replace the OpenGL OCCT OpenGL call renderer with the OCCT Raytracer call" (knowing that it won't be that easy, as the OCCT API is not accessed directly, but through additional wrapper layers...)?

What do you think?
User avatar
quick61
Veteran
Posts: 3803
Joined: Sat Aug 24, 2013 2:49 am
Location: u.S.A.

Re: Materials, physical, optical, for ray tracer and simulat

Post by quick61 »

Coin does that too, (raytracing, real time) and it was discussed about adding the features such as mirror, shadows, lighting etc., but nothing came out of it, (yet). It would be nice to have FreeCAD display scenes like this one in real time.

Qt, OpenSceneGraph, Coin3d -

Image

Mark
This post made with 0.0% Micro$oft products - GOT LINUX?
arust
Posts: 6
Joined: Wed Feb 04, 2015 9:34 am

Re: Materials, physical, optical, for ray tracer and simulat

Post by arust »

quick61 wrote:Coin does that too, [...]
How does this encode material names+properties, how can this interface with FreeCAD?
User avatar
yorik
Founder
Posts: 13642
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Materials, physical, optical, for ray tracer and simulat

Post by yorik »

quick61 wrote:Coin does that too, (raytracing, real time)
Are you sure? Wasn't it opencascade itself?
ickby
Veteran
Posts: 3116
Joined: Wed Oct 05, 2011 7:36 am

Re: Materials, physical, optical, for ray tracer and simulat

Post by ickby »

Coin does unfortunately not do raytracing. They support shadows and advanced material definitions, but by standart opengl methods. Would be nice to use them none the less :)

Coin3d is the scene graph library used by freecad, have a look at their homepage and the book " inventor mentor" which explains the api (coin is a open inventor implementation)

Porting the occ ray tracing to coin would certainly be possible, but a tremendous amount of work. Using it directly in freecad will not work as the graphics frameworks are too different.
User avatar
quick61
Veteran
Posts: 3803
Joined: Sat Aug 24, 2013 2:49 am
Location: u.S.A.

Re: Materials, physical, optical, for ray tracer and simulat

Post by quick61 »

yorik wrote:
quick61 wrote:Coin does that too, (raytracing, real time)
Are you sure? Wasn't it opencascade itself?
ickby wrote:Coin does unfortunately not do raytracing. They support shadows and advanced material definitions, but by standart opengl methods. Would be nice to use them none the less :)
OK, my bad. I thought it was Coin that did the raytracing. I stand corrected. But as ickby says, it would be nice to have the OpenGL stuff in there none the less. Maybe a feature request to target that for 0.16? :)

Mark
This post made with 0.0% Micro$oft products - GOT LINUX?
User avatar
yorik
Founder
Posts: 13642
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Materials, physical, optical, for ray tracer and simulat

Post by yorik »

ickby wrote:Coin does unfortunately not do raytracing. They support shadows and advanced material definitions, but by standart opengl methods. Would be nice to use them none the less :)
Wow, I hadn't seen that... Indeed there is shadows support ( http://coin3d.bitbucket.org/Coin/classS ... Group.html ) yummy! I'll play a bit with that when I have a minute...
Post Reply