static void Export_Emission(Material m, TextureExportManager textureManager, glTFMaterial material) { if (m.IsKeywordEnabled("_EMISSION") == false) { return; } if (m.HasProperty("_EmissionColor")) { var color = m.GetColor("_EmissionColor"); if (color.maxColorComponent > 1) { color /= color.maxColorComponent; } material.emissiveFactor = new float[] { color.r, color.g, color.b }; } if (m.HasProperty("_EmissionMap")) { var index = textureManager.CopyAndGetIndex(m.GetTexture("_EmissionMap"), RenderTextureReadWrite.sRGB); if (index != -1) { material.emissiveTexture = new glTFMaterialEmissiveTextureInfo() { index = index, }; } } }
static void Export_Color(Material m, TextureExportManager textureManager, glTFMaterial material) { if (m.HasProperty("_Color")) { material.pbrMetallicRoughness.baseColorFactor = m.color.linear.ToArray(); } if (m.HasProperty("_MainTex")) { var index = textureManager.CopyAndGetIndex(m.GetTexture("_MainTex"), RenderTextureReadWrite.sRGB); if (index != -1) { material.pbrMetallicRoughness.baseColorTexture = new glTFMaterialBaseColorTextureInfo() { index = index, }; } } }