/
BabylonMaterialAttributes.ms
49 lines (46 loc) · 1.38 KB
/
BabylonMaterialAttributes.ms
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
-- Create Babylon material attributes
CAT_DEF = attributes Babylon_Attributes
version:1
(
Parameters main rollout:params
(
'babylonUnlit' Type:#BOOLEAN UI:'babylonUnlit' Default:False
'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 'babylonAlphaTestPercent' "Alpha Test Cutoff Percent" Width:140 Height:15 Align:#Left Offset:[0,0] Type:#FLOAT Range:[0,1.0, 0]
)
)
-- Add Babylon Attributes to all materials used in the scene
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
(
-- if attribute already exists, update the definition to use this version.
if def.name == #Babylon_Attributes then
(
alreadyAdded = true;
CustAttributes.redefine def CAT_DEF.source
)
)
-- Add babylon material attributes if not present
if alreadyAdded == false then
(
CustAttributes.add mat CAT_DEF;
)
)
else
(
CustAttributes.add mat CAT_DEF;
)
)