Sfoglia il codice sorgente

Do not export metallic roughness map if no specular map is provided
Fix computation of minimal dimensions of several bitmaps

noalak 8 anni fa
parent
commit
44e40f8231

+ 5 - 2
Exporters/3ds Max/Max2Babylon/Exporter/BabylonExporter.GLTFExporter.Material.cs

@@ -196,7 +196,7 @@ namespace Max2Babylon
                                     specular = specularBitmap != null ? new BabylonColor3(specularBitmap.GetPixel(x, y)) :
                                                new BabylonColor3(),
                                     glossiness = babylonStandardMaterial.useGlossinessFromSpecularMapAlpha && specularBitmap != null ? specularBitmap.GetPixel(x, y).A / 255.0f :
-                                                 babylonStandardMaterial.specularPower / 256.0f
+                                                 0
                                 };
 
                                 var displayPrints = x == width / 2 && y == height / 2;
@@ -229,7 +229,10 @@ namespace Max2Babylon
                         // Export maps and textures
                         var baseColorFileName = babylonMaterial.name + "_baseColor" + (hasAlpha ? ".png" : ".jpg");
                         gltfPbrMetallicRoughness.baseColorTexture = ExportBitmapTexture(babylonStandardMaterial.diffuseTexture, baseColorBitmap, baseColorFileName, gltf);
-                        gltfPbrMetallicRoughness.metallicRoughnessTexture = ExportBitmapTexture(babylonStandardMaterial.diffuseTexture, metallicRoughnessBitmap, babylonMaterial.name + "_metallicRoughness" + ".jpg", gltf);
+                        if (specularBitmap != null)
+                        {
+                            gltfPbrMetallicRoughness.metallicRoughnessTexture = ExportBitmapTexture(babylonStandardMaterial.diffuseTexture, metallicRoughnessBitmap, babylonMaterial.name + "_metallicRoughness" + ".jpg", gltf);
+                        }
                     }
                 }
             }

+ 4 - 4
Exporters/3ds Max/Max2Babylon/Exporter/BabylonExporter.Texture.cs

@@ -430,17 +430,17 @@ namespace Max2Babylon
         {
             var haveSameDimensions = true;
 
-            var bitmapsNoNull = new List<Bitmap>(bitmaps).FindAll(bitmap => bitmap != null).ToArray();
+            var bitmapsNoNull = ((new List<Bitmap>(bitmaps)).FindAll(bitmap => bitmap != null)).ToArray();
             if (bitmapsNoNull.Length > 0)
             {
                 // Init with first element
-                width = bitmaps[0].Width;
-                height = bitmaps[0].Height;
+                width = bitmapsNoNull[0].Width;
+                height = bitmapsNoNull[0].Height;
 
                 // Update with others
                 for (int i = 1; i < bitmapsNoNull.Length; i++)
                 {
-                    var bitmap = bitmaps[i];
+                    var bitmap = bitmapsNoNull[i];
                     if (width != bitmap.Width || height != bitmap.Height)
                     {
                         haveSameDimensions = false;