Export metallic and roughness factor only if no metallic roughness texture is present.

This commit is contained in:
kovacsv 2021-07-19 20:17:05 +02:00
parent 7d013878fc
commit 108448fe85
6 changed files with 17 additions and 15 deletions

View File

@ -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;

View File

@ -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) {

View File

@ -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);
}
};

View File

@ -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;

View File

@ -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 ();
}

View File

@ -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);
}