diff --git a/source/export/exportergltf.js b/source/export/exportergltf.js index 1ddc32a..54ba5fd 100644 --- a/source/export/exportergltf.js +++ b/source/export/exportergltf.js @@ -403,9 +403,7 @@ OV.ExporterGltf = class extends OV.ExporterBase let jsonMaterial = { name : obj.GetExportedMaterialName (material.name), pbrMetallicRoughness : { - baseColorFactor : ColorToRGBA (material.color, material.opacity), - metallicFactor : material.metallic, - roughnessFactor : material.roughness + baseColorFactor : ColorToRGBA (material.color, material.opacity) }, emissiveFactor : ColorToRGB (material.emissive), doubleSided : true, @@ -424,10 +422,13 @@ OV.ExporterGltf = class extends OV.ExporterBase } jsonMaterial.pbrMetallicRoughness.baseColorTexture = baseColorTexture; } - let metallicTexture = GetTextureParams (mainJson, material.metallicMap, addTexture); + let metallicTexture = GetTextureParams (mainJson, material.metalnessMap, addTexture); if (metallicTexture !== null) { jsonMaterial.pbrMetallicRoughness.metallicRoughnessTexture = metallicTexture; - } + } else { + jsonMaterial.pbrMetallicRoughness.metallicFactor = material.metalness; + jsonMaterial.pbrMetallicRoughness.roughnessFactor = material.roughness; + } let normalTexture = GetTextureParams (mainJson, material.normalMap, addTexture); if (normalTexture !== null) { jsonMaterial.normalTexture = normalTexture; diff --git a/source/import/importergltf.js b/source/import/importergltf.js index 4524b04..bc297d8 100644 --- a/source/import/importergltf.js +++ b/source/import/importergltf.js @@ -753,7 +753,7 @@ OV.ImporterGltf = class extends OV.ImporterBase } material.diffuseMap = this.ImportTexture (gltf, gltfMaterial.pbrMetallicRoughness.baseColorTexture); - material.metallicMap = this.ImportTexture (gltf, gltfMaterial.pbrMetallicRoughness.metallicRoughnessTexture); + material.metalnessMap = this.ImportTexture (gltf, gltfMaterial.pbrMetallicRoughness.metallicRoughnessTexture); material.normalMap = this.ImportTexture (gltf, gltfMaterial.normalTexture); material.emissiveMap = this.ImportTexture (gltf, gltfMaterial.emissiveTexture); if (material.diffuseMap !== null) { diff --git a/source/model/material.js b/source/model/material.js index 82faf32..041b1ef 100644 --- a/source/model/material.js +++ b/source/model/material.js @@ -82,7 +82,7 @@ OV.Material = class this.specular = new OV.Color (0, 0, 0); this.emissive = new OV.Color (0, 0, 0); - this.metallic = 0.0; + this.metalness = 0.0; this.roughness = 1.0; this.shininess = 0.0; // 0.0 .. 1.0 @@ -93,11 +93,12 @@ OV.Material = class this.bumpMap = null; this.normalMap = null; this.emissiveMap = null; - this.metallicMap = null; + this.metalnessMap = null; this.alphaTest = 0.0; // 0.0 .. 1.0 this.transparent = false; this.multiplyDiffuseMap = false; + this.multiplyMetallicMap = false; this.isDefault = false; } @@ -113,7 +114,7 @@ OV.Material = class cloned.specular = this.specular.Clone (); cloned.emissive = this.emissive.Clone (); - cloned.metallic = this.metallic; + cloned.metalness = this.metalness; cloned.roughness = this.roughness; cloned.shininess = this.shininess; @@ -124,7 +125,7 @@ OV.Material = class cloned.bumpMap = this.CloneTextureMap (this.bumpMap); cloned.normalMap = this.CloneTextureMap (this.normalMap); cloned.emissiveMap = this.CloneTextureMap (this.emissiveMap); - cloned.metallicMap = this.CloneTextureMap (this.metallicMap); + cloned.metalnessMap = this.CloneTextureMap (this.metalnessMap); cloned.alphaTest = this.alphaTest; cloned.transparent = this.transparent; @@ -216,7 +217,7 @@ OV.EnumerateMaterialTextureMaps = function (material, enumerator) if (material.emissiveMap !== null) { enumerator (material.emissiveMap); } - if (material.metallicMap !== null) { - enumerator (material.metallicMap); + if (material.metalnessMap !== null) { + enumerator (material.metalnessMap); } }; diff --git a/source/threejs/threeconverter.js b/source/threejs/threeconverter.js index 9f9b995..31e4b50 100644 --- a/source/threejs/threeconverter.js +++ b/source/threejs/threeconverter.js @@ -77,7 +77,7 @@ OV.ConvertModelToThreeMeshes = function (model, params, output, callbacks) threeMaterial = new THREE.MeshStandardMaterial (materialParams); threeMaterial.metalness = material.metalness; threeMaterial.roughness = material.roughness; - LoadTexture (threeMaterial, material.metallicMap, (threeTexture) => { + LoadTexture (threeMaterial, material.metalnessMap, (threeTexture) => { threeMaterial.metalness = 1.0; threeMaterial.roughness = 1.0; threeMaterial.metalnessMap = threeTexture; diff --git a/website/o3dv/detailssidebarpanel.js b/website/o3dv/detailssidebarpanel.js index 05981d9..2d536ef 100644 --- a/website/o3dv/detailssidebarpanel.js +++ b/website/o3dv/detailssidebarpanel.js @@ -70,7 +70,7 @@ OV.DetailsSidebarPanel = class extends OV.SidebarPanel AddTextureMap (this, table, 'Bump Map', material.bumpMap); AddTextureMap (this, table, 'Normal Map', material.normalMap); AddTextureMap (this, table, 'Emissive Map', material.emissiveMap); - AddTextureMap (this, table, 'Metallic Map', material.metallicMap); + AddTextureMap (this, table, 'Metallic Map', material.metalnessMap); this.Resize (); } diff --git a/website/o3dv/website.js b/website/o3dv/website.js index 2064068..487aad5 100644 --- a/website/o3dv/website.js +++ b/website/o3dv/website.js @@ -240,7 +240,7 @@ OV.Website = class 'assets/envmaps/fishermans_bastion/negy.jpg', 'assets/envmaps/fishermans_bastion/posz.jpg', 'assets/envmaps/fishermans_bastion/negz.jpg' - ]); + ]); this.ShowViewer (false); }