@@ -23,41 +23,71 @@ public static void ConfigureCompression(EditingKitInfo editingKit, string tag_fo
23
23
24
24
var bitmaps_to_import = GetBitmapsToImport ( editingKit , tag_folder ) ;
25
25
26
- // Define bitmap name suffixes for anything non-diffuse
27
- string [ ] normal_suffixes =
28
- {
29
- "_normal" ,
30
- "_normalmap" ,
31
- "_nm" ,
32
- "_n" ,
33
- "_zbump"
26
+ var mainSuffixRules = new Dictionary < string , Action < TagFileBitmap > > ( StringComparer . OrdinalIgnoreCase )
27
+ {
28
+ // Normal maps
29
+ { "_normal" , ApplySettingsNormals } ,
30
+ { "_normalmap" , ApplySettingsNormals } ,
31
+ { "_nm" , ApplySettingsNormals } ,
32
+ { "_n" , ApplySettingsNormals } ,
33
+ { "_zbump" , ApplySettingsNormals } ,
34
+
35
+ // Bump maps
36
+ { "_bump" , ApplySettingsBumps } ,
37
+ { "_bmp" , ApplySettingsBumps } ,
38
+ { "_bp" , ApplySettingsBumps } ,
39
+ { "_b" , ApplySettingsBumps } ,
40
+
41
+ // Material maps
42
+ { "_material" , ApplySettingsMaterials } ,
43
+ { "_materialmap" , ApplySettingsMaterials } ,
44
+ { "_mat" , ApplySettingsMaterials } ,
45
+ { "_m" , ApplySettingsMaterials } ,
46
+ { "_orm" , ApplySettingsMaterials } ,
47
+ { "_ormh" , ApplySettingsMaterials } ,
48
+ { "_rmo" , ApplySettingsMaterials } ,
49
+ { "_rmoh" , ApplySettingsMaterials } ,
50
+ { "_mro" , ApplySettingsMaterials } ,
51
+ { "_mroh" , ApplySettingsMaterials } ,
34
52
} ;
35
53
36
- string [ ] bump_suffixes =
37
- {
38
- "_bump" ,
39
- "_bmp" ,
40
- "_bp" ,
41
- "_b"
42
- } ;
43
-
44
- string [ ] material_suffixes =
45
- {
46
- "_material" ,
47
- "_materialmap" ,
48
- "_mat" ,
49
- "_m" ,
50
- "_orm" ,
51
- "_ormh" ,
52
- "_rmo" ,
53
- "_rmoh" ,
54
- "_mro" ,
55
- "_mroh"
54
+ var miscSuffixRules = new Dictionary < string , string > ( StringComparer . OrdinalIgnoreCase )
55
+ {
56
+ //{ "_3d", "3D Texture" }, - crashes tool, disabling
57
+ { "_blend" , "Blend Map (linear for terrains)" } ,
58
+ { "_terrainblend" , "Blend Map (linear for terrains)" } ,
59
+ { "_cc" , "Change Color Map" } ,
60
+ { "_change" , "Change Color Map" } ,
61
+ { "_changecolor" , "Change Color Map" } ,
62
+ { "_cube" , "Cube Map (Reflection Map)" } ,
63
+ { "_cubemap" , "Cube Map (Reflection Map)" } ,
64
+ { "_detail" , "Detail Map" } ,
65
+ { "_detailbump" , "Detail Bump Map (from Height Map - fades out)" } ,
66
+ { "_dsprite" , "Sprite (Double Multiply, Gray Background)" } ,
67
+ { "_float" , "Float Map (WARNING" } ,
68
+ { "_height" , "Height Map (for Parallax)" } ,
69
+ { "_heightmap" , "Height Map (for Parallax)" } ,
70
+ { "_parallax" , "Height Map (for Parallax)" } ,
71
+ { "_displacement" , "Height Map (for Parallax)" } ,
72
+ { "_illum" , "Self-Illum Map" } ,
73
+ { "_illumination" , "Self-Illum Map" } ,
74
+ { "_selfillum" , "Self-Illum Map" } ,
75
+ { "_emissive" , "Self-Illum Map" } ,
76
+ //{ "_lactxl", ApplySettingsMisc }, - unimplemented?
77
+ //{ "_ladxn", ApplySettingsMisc }, - unimplemented?
78
+ { "_msprite" , "Sprite (Blend, White Background)" } ,
79
+ { "_spec" , "Specular Map" } ,
80
+ { "_specular" , "Specular Map" } ,
81
+ { "_sprite" , "Sprite (Additive, Black Background)" } ,
82
+ { "_ui" , "Interface Bitmap" } ,
83
+ { "_vec" , "Vector Map" } ,
84
+ { "_vector" , "Vector Map" } ,
85
+ { "_warp" , "Warp Map (EMBM)" } ,
56
86
} ;
57
87
58
88
void ApplySettingsDiffuse ( TagFileBitmap bitmapFile )
59
89
{
60
- bitmapFile . ResetUsageOverrides ( ) ;
90
+ bitmapFile . ResetUsageOverride ( ) ;
61
91
bitmapFile . CurveValue = "force PRETTY" ;
62
92
bitmapFile . BitmapFormatValue = compress_value ;
63
93
bitmapFile . MipMapLevel . Data = - 1 ;
@@ -75,7 +105,7 @@ void ApplySettingsDiffuse(TagFileBitmap bitmapFile)
75
105
76
106
void ApplySettingsNormals ( TagFileBitmap bitmapFile )
77
107
{
78
- bitmapFile . ResetUsageOverrides ( ) ;
108
+ bitmapFile . ResetUsageOverride ( ) ;
79
109
80
110
bitmapFile . UsageValue = "ZBrush Bump Map (from Bump Map)" ; // 17
81
111
@@ -102,7 +132,7 @@ void ApplySettingsNormals(TagFileBitmap bitmapFile)
102
132
103
133
void ApplySettingsBumps ( TagFileBitmap bitmapFile )
104
134
{
105
- bitmapFile . ClearUsageOverrides ( ) ;
135
+ bitmapFile . RemoveUsageOverride ( ) ;
106
136
107
137
bitmapFile . UsageValue = "Bump Map (from Height Map)" ; // 2
108
138
bitmapFile . BumpHeight . Data = 5 ; // use 5 as the default value
@@ -113,7 +143,7 @@ void ApplySettingsBumps(TagFileBitmap bitmapFile)
113
143
114
144
void ApplySettingsMaterials ( TagFileBitmap bitmapFile )
115
145
{
116
- bitmapFile . ResetUsageOverrides ( ) ;
146
+ bitmapFile . ResetUsageOverride ( ) ;
117
147
118
148
bitmapFile . CurveValue = "force PRETTY" ;
119
149
bitmapFile . BitmapFormatValue = compress_value ;
@@ -125,10 +155,18 @@ void ApplySettingsMaterials(TagFileBitmap bitmapFile)
125
155
bitmapFile . UsageFormatValue = compress_value ;
126
156
}
127
157
158
+ void ApplySettingsMisc ( TagFileBitmap bitmapFile , string usage )
159
+ {
160
+ bitmapFile . RemoveUsageOverride ( ) ;
161
+ bitmapFile . UsageValue = usage ;
162
+ bitmapFile . CurveValue = "force PRETTY" ;
163
+ bitmapFile . BitmapFormatValue = compress_value ;
164
+ }
165
+
128
166
foreach ( string bitmap in bitmaps_to_import )
129
167
{
130
168
/*
131
- * Figure otu of the tag exists, and if it does, if we should modify it
169
+ * Figure out of the tag exists, and if it does, if we should modify it
132
170
*/
133
171
134
172
TagPath tag_path = TagPath . FromPathAndType ( bitmap , "bitm*" ) ;
@@ -155,21 +193,35 @@ void ApplySettingsMaterials(TagFileBitmap bitmapFile)
155
193
* Apply custom settings depending on the bitmap usage (based on filename)
156
194
*/
157
195
158
- if ( normal_suffixes . Any ( suffix => bitmap . EndsWith ( suffix ) ) )
196
+ bool applied = false ;
197
+ // Check main suffix dictionary
198
+ foreach ( var rule in mainSuffixRules )
159
199
{
160
- ApplySettingsNormals ( tagBitmap ) ;
161
- }
162
- else if ( bump_suffixes . Any ( suffix => bitmap . EndsWith ( suffix ) ) )
163
- {
164
- ApplySettingsBumps ( tagBitmap ) ;
200
+ if ( bitmap . EndsWith ( rule . Key , StringComparison . OrdinalIgnoreCase ) )
201
+ {
202
+ rule . Value ( tagBitmap ) ;
203
+ applied = true ;
204
+ break ;
205
+ }
165
206
}
166
- else if ( material_suffixes . Any ( suffix => bitmap . EndsWith ( suffix ) ) )
207
+
208
+ if ( ! applied )
167
209
{
168
- ApplySettingsMaterials ( tagBitmap ) ;
210
+ // Check misc suffix dictionary
211
+ foreach ( var rule in miscSuffixRules )
212
+ {
213
+ if ( bitmap . EndsWith ( rule . Key , StringComparison . OrdinalIgnoreCase ) )
214
+ {
215
+ ApplySettingsMisc ( tagBitmap , rule . Value ) ;
216
+ applied = true ;
217
+ break ;
218
+ }
219
+ }
169
220
}
170
- else
221
+
222
+ // Default to diffuse if no valid suffix
223
+ if ( ! applied )
171
224
{
172
- // default to treating bitmaps as diffuse
173
225
ApplySettingsDiffuse ( tagBitmap ) ;
174
226
}
175
227
@@ -243,7 +295,7 @@ public static TagFileBitmap FromFullPath(EditingKitInfo editingKit, string fullP
243
295
return new TagFileBitmap ( tag_style_path ) ;
244
296
}
245
297
246
- public void ResetUsageOverrides ( )
298
+ public void ResetUsageOverride ( )
247
299
{
248
300
// clear any old data
249
301
UsageOverridesBlock . RemoveAllElements ( ) ;
@@ -252,7 +304,7 @@ public void ResetUsageOverrides()
252
304
UsageOverridesBlock . AddElement ( ) ;
253
305
}
254
306
255
- public void ClearUsageOverrides ( )
307
+ public void RemoveUsageOverride ( )
256
308
{
257
309
UsageOverridesBlock . RemoveAllElements ( ) ;
258
310
}
0 commit comments