Turns a glTF or FBX material's numbers (roughness, index of refraction, film thickness, emission strength) into the renderer's parameters and back.
How the precision is kept
Each parameter is copied or converted in 64-bit, and every number in the result is then rounded to 7 significant digits with toPrecision(7). The values describe how a surface is shaded; they are kept on the import report.
Open item. Keep the converted parameters unrounded; toPrecision(7) drops digits the source file had.
Calculations under this policy
4 calculations in 1 source file. The code is read from the released app when this page loads. It is the calculation people run, not a copy kept for this page.
v → the number nearest v with 7 significant digits
Number(v.toPrecision(7)) is applied to every numeric parameter and to each number of every list before the material is returned. This rounds the stored value, not a display.
A roughness from a Blinn–Phong shininess exponent.
roughness = (2 ÷ (s + 2))^¼, clamped to [0, 1]
Two square roots of a quotient whose denominator is at least 2, because the exponent is floored at 0. The code's comment names it the usual published conversion.
io/pbr.js
lines 147 to 148
ModelCraft 0.8.1
const s = Math.max(0, n('ShininessExponent') ?? n('Shininess'));
p.specular_roughness = clamp01(Math.sqrt(Math.sqrt(2 / (s + 2))));
In detail
Method
Direct mappings between the two material models; a shininess exponent becomes a roughness by a published conversion.
Number types
64-bit numbers, rounded to 7 significant digits at the end.
Tolerances
An emission strength within 1e-6 of 1 is not written to glTF. An emission peak is floored at 1e-9 on the way back to glTF.
Limits
Every parameter keeps 7 significant digits.
Approach: 64-bit, direct
Every value is a 64-bit number from input to result. Formulas are closed form or a direct solve, and every comparison uses a stated tolerance.