mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-09-14 14:59:43 -05:00
Merge pull request #102 from saturday06/limit-gltf-material-emissiveFactor
Round glTF2.0 materials[].emissiveFactor value to its maximum limit
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using NUnit.Framework;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace UniGLTF
|
||||
@@ -176,5 +177,17 @@ namespace UniGLTF
|
||||
Assert.AreEqual("Standard", material.shader.name);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MaterialExportTest()
|
||||
{
|
||||
var material = new Material(Shader.Find("Standard"));
|
||||
material.SetColor("_EmissionColor", new Color(0, 1, 2, 1));
|
||||
var materialExporter = new MaterialExporter();
|
||||
var textureExportManager = new TextureExportManager(new Texture[] { });
|
||||
var gltfMaterial = materialExporter.ExportMaterial(material, textureExportManager);
|
||||
|
||||
Assert.AreEqual(gltfMaterial.emissiveFactor, new float[] { 0, 0.5f, 1 });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,6 +135,10 @@ namespace UniGLTF
|
||||
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 };
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user