Skip to content

Commit a5ad7cb

Browse files
authored
Merge pull request #968 from pandaGaume/Change-BumpMap-att
Fixes event issue on adding attribute to normalMaps
2 parents 0f74975 + 773d03a commit a5ad7cb

File tree

2 files changed

+27
-30
lines changed

2 files changed

+27
-30
lines changed

3ds Max/Max2Babylon/MaterialScripts.cs

Lines changed: 17 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -20,41 +20,28 @@ public static string AddCustomAttribute( this string decl, string container, str
2020
l = custAttributes.count mat;
2121
for i = 1 to l+1 do (
2222
if(mat.custAttributes[i] != undefined) then (
23-
if(mat.custAttributes[i].name == attName) then return true
24-
) ) return false )";
23+
if(mat.custAttributes[i].name == attName) then
24+
(
25+
return true
26+
)
27+
) ) return false )";
2528

26-
/// <summary>
27-
/// Note : We may run a check on all Slate view, because race condition into script execution
28-
/// do not ensure the link beetwen material and bump are correctly set when material is updated.
29-
/// </summary>
30-
public static string CheckBumpMap = $@"fn checkBumpMap = (
31-
local babylonAttName = ""Babylon Attributes""
32-
for v=1 to sme.GetNumViews() do
33-
(
34-
viewNode = sme.GetView(v)
35-
for i=1 to viewNode.GetNumNodes() do
36-
(
37-
n = viewNode.GetNode i;
38-
if(classof n.reference == Normal_Bump ) then
39-
(
40-
nbump = n.reference
41-
if(hasBabylonCustomAttribute nbump babylonAttName == false ) then
42-
(
43-
{BumpMapCAtDef}
44-
custAttributes.add nbump BUMP_MAP_CAT_DEF
45-
)
46-
)
47-
)
48-
)
49-
)";
29+
public static string CheckBumpMap = $@"fn checkBumpMap map = (
30+
local babylonAttName = ""Babylon Attributes""
31+
if(map != undefined) then
32+
(
33+
if( classof map == Normal_Bump ) then
34+
(
35+
if( hasBabylonCustomAttribute map babylonAttName == false) then
36+
(
37+
{BumpMapCAtDef}
38+
custAttributes.add map BUMP_MAP_CAT_DEF
39+
))))";
5040

51-
/// There is NO WAY to get an even on BumpMap creation into the Slate editor. Only Material creation is triggered.
52-
/// This is the reason we listen for parameters Material change
5341
private static string AddPhysicalBabylonUI =
5442
$@"if ( hasBabylonCustomAttribute maxMaterial ""Babylon Attributes"" == false) then (
55-
{PhysicalBabylonCAtDef}
43+
{PhysicalBabylonCAtDef}
5644
custAttributes.add maxMaterial PHYSICAL_MATERIAL_CAT_DEF
57-
when parameters maxMaterial change do checkBumpMap()
5845
)";
5946

6047
public static string AddCallback => $@"addMaterialCallbackScript = ""maxMaterial = callbacks.notificationParam();

3ds Max/Max2Babylon/Scripts/PHYSICAL_MATERIAL_CAT_DEF.ms

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,15 @@ version:2
4747
label babylonTransparencyMode_label "Transparency Mode " Align: #Left across:2
4848
dropdownlist babylonTransparencyMode_dd items:# ("Opaque","Cutoff","Blend") selection:(babylonTransparencyMode+1) Align: #Right
4949
on babylonTransparencyMode_dd selected i do babylonTransparencyMode = i-1
50+
51+
button BumpBtn "Add Normal bump(s) attributes" tooltip:"Adds additional attributes to normal maps to help the exporter manage the input format."
52+
on BumpBtn pressed do
53+
(
54+
local activMaterial = sme.GetMtlInParamEditor()
55+
-- for PhysicalMaterial
56+
if( hasProperty activMaterial "bump_map" ) then checkBumpMap(activMaterial.bump_map)
57+
-- for PBRMetalRough and PBRSpecGloss
58+
if( hasProperty activMaterial "norm_map" ) then checkBumpMap(activMaterial.norm_map)
59+
)
5060
)
5161
)

0 commit comments

Comments
 (0)