static void Export_Metallic(Material m, TextureExportManager textureManager, glTFMaterial material) { int index = -1; if (m.HasProperty("_MetallicGlossMap")) { index = textureManager.ConvertAndGetIndex(m.GetTexture("_MetallicGlossMap"), new MetallicRoughnessConverter()); if (index != -1) { material.pbrMetallicRoughness.metallicRoughnessTexture = new glTFMaterialMetallicRoughnessTextureInfo() { index = index, }; } } if (index != -1 && m.HasProperty("_GlossMapScale")) { material.pbrMetallicRoughness.metallicFactor = 1.0f; material.pbrMetallicRoughness.roughnessFactor = 1.0f - m.GetFloat("_GlossMapScale"); } else { if (m.HasProperty("_Metallic")) { material.pbrMetallicRoughness.metallicFactor = m.GetFloat("_Metallic"); } if (m.HasProperty("_Glossiness")) { material.pbrMetallicRoughness.roughnessFactor = 1.0f - m.GetFloat("_Glossiness"); } } }
static void Export_Metallic(Material m, TextureExportManager textureManager, glTFMaterial material) { int index = -1; if (m.HasProperty("_MetallicGlossMap")) { float smoothness = 0.0f; if (m.HasProperty("_GlossMapScale")) { smoothness = m.GetFloat("_GlossMapScale"); } // Bake smoothness values into a texture. var converter = new MetallicRoughnessConverter(smoothness); index = textureManager.ConvertAndGetIndex(m.GetTexture("_MetallicGlossMap"), converter); if (index != -1) { material.pbrMetallicRoughness.metallicRoughnessTexture = new glTFMaterialMetallicRoughnessTextureInfo() { index = index, }; Export_MainTextureTransform(m, material.pbrMetallicRoughness.metallicRoughnessTexture); } } if (index != -1) { material.pbrMetallicRoughness.metallicFactor = 1.0f; // Set 1.0f as hard-coded. See: https://github.com/dwango/UniVRM/issues/212. material.pbrMetallicRoughness.roughnessFactor = 1.0f; } else { if (m.HasProperty("_Metallic")) { material.pbrMetallicRoughness.metallicFactor = m.GetFloat("_Metallic"); } if (m.HasProperty("_Glossiness")) { material.pbrMetallicRoughness.roughnessFactor = 1.0f - m.GetFloat("_Glossiness"); } } }
static void Export_Occlusion(Material m, TextureExportManager textureManager, glTFMaterial material) { if (m.HasProperty("_OcclusionMap")) { var index = textureManager.ConvertAndGetIndex(m.GetTexture("_OcclusionMap"), new OcclusionConverter()); if (index != -1) { material.occlusionTexture = new glTFMaterialOcclusionTextureInfo() { index = index, }; } if (index != -1 && m.HasProperty("_OcclusionStrength")) { material.occlusionTexture.strength = m.GetFloat("_OcclusionStrength"); } } }
static void Export_Normal(Material m, TextureExportManager textureManager, glTFMaterial material) { if (m.HasProperty("_BumpMap")) { var index = textureManager.ConvertAndGetIndex(m.GetTexture("_BumpMap"), new NormalConverter()); if (index != -1) { material.normalTexture = new glTFMaterialNormalTextureInfo() { index = index, }; } if (index != -1 && m.HasProperty("_BumpScale")) { material.normalTexture.scale = m.GetFloat("_BumpScale"); } } }