modelica / ModelicaStandardLibrary

Free (standard conforming) library to model mechanical (1D/3D), electrical (analog, digital, machines), magnetic, thermal, fluid, control systems and hierarchical state machines. Also numerical functions and functions for strings, files and streams are included.
https://doc.modelica.org
BSD 3-Clause "New" or "Revised" License
479 stars 169 forks source link

How should specular coefficient be applied? #4083

Open anotheruserofgithub opened 1 year ago

anotheruserofgithub commented 1 year ago

Questions:

  1. https://github.com/modelica/ModelicaStandardLibrary/blob/2308ab206ffa874188d24b64962fa42dfeb3c81f/Modelica/Mechanics/MultiBody/Types/SpecularCoefficient.mo#L2 -> Why no max=1?
  2. Not all components default to world.defaultSpecularCoefficient -> Is that intentional or should it be fixed?
  3. From the references below, I understand that instead of a single specular coefficient, there should be a specular color and a specular exponent (shininess), meaning, there are usually two degrees of freedom (color and shininess) to define the specular component. But with a single coefficient, I assume that it is meant to scale a white specular color, and that the shininess is fixed arbitrarily. That's how I implemented it for OpenModelica (see this commit of https://github.com/OpenModelica/OpenModelica/pull/10362), trying to get as close as possible to the example images below. Did I misunderstand something? @HansOlsson Maybe you would be able to give me a deeper insight and share how this is done in Dymola for instance?

References:

Examples:

tobolar commented 1 year ago

The usage of the specular coefficient seems not to be done consequently.

(but in other visualizers, the default world.defaultSpecularCoefficient is indeed used, e.g. Modelica.Mechanics.MultiBody.Visualizers.SignalArrow

anotheruserofgithub commented 1 year ago

Any answer to question 3? Maybe @HansOlsson?

HansOlsson commented 1 year ago

Any answer to question 3? Maybe @HansOlsson?

As far as I can see it is a multiplicative factor for the color; so a red ball can only have various levels of red specular color. The shininess is not influenced.

anotheruserofgithub commented 1 year ago

Thank you! I will try that.

anotheruserofgithub commented 1 year ago

Well, after more experiments, it really seems to me that the specular coefficient is meant to multiply a white specular color with a fixed shininess around 8 (OpenGL). Explicit support for a shininess input in MSL would be great, otherwise vendor-specific annotations can be put in place if there is any use case for that.

tobolar commented 1 year ago

@anotheruserofgithub Feel free to suggest a necessary documentation in e.g. Modelica.Mechanics.MultiBody.UsersGuide.Tutorial.