mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-09-10 21:09:08 -05:00
Refer to vertex color when importing with UniUnlit
This commit is contained in:
@@ -170,10 +170,7 @@ namespace UniGLTF
|
||||
var materialImporter = new MaterialImporter(shaderStore, null);
|
||||
|
||||
{
|
||||
var material = materialImporter.CreateMaterial(0, new glTFMaterial
|
||||
{
|
||||
|
||||
});
|
||||
var material = materialImporter.CreateMaterial(0, new glTFMaterial { }, false);
|
||||
Assert.AreEqual("Standard", material.shader.name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -625,13 +625,13 @@ namespace UniGLTF
|
||||
{
|
||||
if (GLTF.materials == null || !GLTF.materials.Any())
|
||||
{
|
||||
AddMaterial(MaterialImporter.CreateMaterial(0, null));
|
||||
AddMaterial(MaterialImporter.CreateMaterial(0, null, false));
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < GLTF.materials.Count; ++i)
|
||||
{
|
||||
AddMaterial(MaterialImporter.CreateMaterial(i, GLTF.materials[i]));
|
||||
AddMaterial(MaterialImporter.CreateMaterial(i, GLTF.materials[i], GLTF.MaterialHasVertexColor(i)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace UniGLTF
|
||||
{
|
||||
public interface IMaterialImporter
|
||||
{
|
||||
Material CreateMaterial(int i, glTFMaterial src);
|
||||
Material CreateMaterial(int i, glTFMaterial src, bool hasVertexColor);
|
||||
}
|
||||
|
||||
public class MaterialImporter : IMaterialImporter
|
||||
@@ -64,7 +64,7 @@ namespace UniGLTF
|
||||
/// _SrcBlend
|
||||
/// _DstBlend
|
||||
/// _ZWrite
|
||||
public virtual Material CreateMaterial(int i, glTFMaterial x)
|
||||
public virtual Material CreateMaterial(int i, glTFMaterial x, bool hasVertexColor)
|
||||
{
|
||||
var shader = m_shaderStore.GetShader(x);
|
||||
//Debug.LogFormat("[{0}]{1}", i, shader.name);
|
||||
@@ -134,6 +134,12 @@ namespace UniGLTF
|
||||
UniUnlit.Utils.SetCullMode(material, UniUnlit.UniUnlitCullMode.Back);
|
||||
}
|
||||
|
||||
// VColor
|
||||
if (hasVertexColor)
|
||||
{
|
||||
UniUnlit.Utils.SetVColBlendMode(material, UniUnlit.UniUnlitVertexColorBlendOp.Multiply);
|
||||
}
|
||||
|
||||
UniUnlit.Utils.ValidateProperties(material, true);
|
||||
|
||||
return material;
|
||||
|
||||
@@ -59,6 +59,11 @@ namespace UniGLTF.UniUnlit
|
||||
material.SetInt(PropNameCullMode, (int) mode);
|
||||
}
|
||||
|
||||
public static void SetVColBlendMode(Material material, UniUnlitVertexColorBlendOp mode)
|
||||
{
|
||||
material.SetInt(PropNameVColBlendMode, (int)mode);
|
||||
}
|
||||
|
||||
public static UniUnlitRenderMode GetRenderMode(Material material)
|
||||
{
|
||||
return (UniUnlitRenderMode)material.GetInt(PropNameBlendMode);
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace VRM
|
||||
"VRM/UnlitTransparentZWrite",
|
||||
};
|
||||
|
||||
public override Material CreateMaterial(int i, glTFMaterial src)
|
||||
public override Material CreateMaterial(int i, glTFMaterial src, bool hasVertexColor)
|
||||
{
|
||||
if(i==0 && m_materials.Count == 0)
|
||||
{
|
||||
@@ -50,7 +50,7 @@ namespace VRM
|
||||
{
|
||||
Debug.LogWarningFormat("unknown shader {0}.", shaderName);
|
||||
}
|
||||
return base.CreateMaterial(i, src);
|
||||
return base.CreateMaterial(i, src, hasVertexColor);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user