Hello!
What I want to do is to export from 3ds Max as a gltf with custom values of the metallicFactor.
What I do is to add Custom Attribute to Physical material in 3ds Max and to use this CA to set the Metallic value of the material.
This is the code that I use:
(
-- Create Babylon material attributes
CAT_DEF1 = attributes Babylon_Attributes
(
Parameters main rollout:params
(
metallicFactor Type:#float UI:metallicFactor default:0.7
-- babylonAlphaTest Type:#BOOLEAN UI:babylonAlphaTest Default:False
-- babylonAlphaTestPercent Type:#FLOAT UI:babylonAlphaTestPercent Default:0.50
)
Rollout Params "Babylon Attributes"
(
-- checkbox babylonUnlit "Unlit" Width:70 Height:15 Align:#Left Offset:[0,0] Type:#BOOLEAN
-- checkbox babylonAlphaTest "Alpha Test" Width:70 Height:15 Align:#Left Offset:[0,0] Type:#BOOLEAN
spinner metallicFactor "Metallic" width:140 height:15 align:#Left offset:[0,0] type:#FLOAT Range:[0.0,1.0, 0]
)
)
for mat in scenematerials do
(
print ("Adding attributes to " + mat.name)
defs = custAttributes.getDefs mat;
if defs != undefined then
(
--Check if babylon material attributes are present
alreadyAdded = false;
for def in defs do
(
format "def.name: % \n" def.name
-- if attribute already exists, update the definition to use this version.
if def.name == #Babylon_Attributes then
(
alreadyAdded = true;
CustAttributes.redefine def CAT_DEF1.source
)
)
-- Add babylon material attributes if not present
if alreadyAdded == false then
(
CustAttributes.add mat CAT_DEF1;
)
)
else
(
CustAttributes.add mat CAT_DEF1;
)
)
)
The metallicFactor has to be the proper parameter to be set to desired value.
If I have an object in the scene with Physical material applied and I run the code above the CA is created and when I open the Material Editor I can see the “Metallic” spinner and I can change its value. If I select the object and then execute:
selection[1].material.metallicfactor
in the MaxScript Listener is printed the current value.
But, when I export as gltf, using the default Babylon Exporter or my custom exporter the Metallic slider(under Metaillc Workflow group of controls) always shows 1.0. The value of the spinner in the Material Editor is not exported as a valid parameter and in my browser Babylon.
I just saw that there is thread, posted 3h ago, with almost the same question.