It is possible to set mesh material colors by using oapi.set_materialex(hdevmesh, mat_id, MATPROP.<DESCRIPTOR>, color). But I am trying to map the MATPROP specs to what they control in the material definition in the mesh file. Some things are obvious, but some are not, and the documentation text isn't completely clear on some points.
I found the following documentation in the GitHub repositories in Lua syntax, and there is a nearly identical description of MatProp enumerators on page 519 of the Orbiter API reference:
The material specification in the mesh file looks like this:
I found the following documentation in the GitHub repositories in Lua syntax, and there is a nearly identical description of MatProp enumerators on page 519 of the Orbiter API reference:
Code:
MATPROP.DIFFUSE Material Diffuse color or Albedo depending on shader used. [.rgba]
MATPROP.AMBIENT Ambient color or Ambien occlusion [.rgb]
MATPROP.SPECULAR Specular color [.rgb] power in [.a]
MATPROP.LIGHT DX7 Style emission (color is added in light that lits the diffuse texture) (i.e. light map) [.rgb]
MATPROP.EMISSION Still in a development currently: output = max(diffuse*light, emission) [.rgb]
MATPROP.REFLECT Reflectivity [.rgb]
MATPROP.SMOOTH Smoothness in [.r] (1 = smooth, 0 = rough)
MATPROP.METAL Metalness in [.r] (1 = metal, 0 = non-metal)
MATPROP.FRESNEL Fresnel terms for fresnel effect. Used in older 2nd generation shader.
MATPROP.SPECIALFX Heat map effect control variable in [.r] (i.e. average part temperature)
The material specification in the mesh file looks like this:
Code:
MATERIAL Main
0.161 0.216 0.176 1.000
0.438 0.502 0.457 1.000
0.438 0.502 0.457 1.000 0.000
0.000 0.000 0.000 0.000
- The first line of numbers is the diffuse rgba color, which can be enumerated with MATPROP.DIFFUSE.
- The second line is the ambient rgba color, which can be enumerated with MATPROP.AMBIENT, though I am not sure the alpha channel is used as the documentation indicates "[rgb]".
- The third line is specular rgba color, with a reflectivity power. I'm assuming the color can be enumerated with MATPROP.SPECULAR, but the documentation states "Specular color [.rgb] power in [.a]", so I am unsure if it requires an [rgb] color, an [rgba] color, or is actually setting a power level. The method fails if I simply apply a number so I am assuming it must be a color vector of some sort.
- The fourth line is the emissive rgb color, which is enumerated by MATPROP.LIGHT.