mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-05-14 14:29:52 -05:00
Merge pull request #1649 from Santarh/uvExpressionFix
Ignore duplicated UV expression in migration.
This commit is contained in:
commit
d15bb4cb07
|
|
@ -231,21 +231,9 @@ namespace UniVRM10
|
|||
{
|
||||
{"Standard", new string[]{
|
||||
"_MainTex_ST",
|
||||
"_BumpMap_ST",
|
||||
"_EmissionMap_ST",
|
||||
"_MetallicGlossMap_ST",
|
||||
"_ParallaxMap_ST",
|
||||
}},
|
||||
{"VRM10/MToon10", new string[]{
|
||||
"_MainTex_ST",
|
||||
"_ShadeTexture_ST",
|
||||
"_BumpMap_ST",
|
||||
"_EmissionMap_ST",
|
||||
"_OutlineWidthTexture_ST",
|
||||
"_ReceiveShadowTexture_ST",
|
||||
"_RimTexture_ST",
|
||||
"_ShadingGradeTexture_ST",
|
||||
"_UvAnimMaskTexture_ST",
|
||||
}},
|
||||
};
|
||||
static string[] DefaultProps = { "_MainTex_ST" };
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ namespace UniVRM10
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <param name="vrm1Data"></param>
|
||||
|
|
@ -80,21 +80,21 @@ namespace UniVRM10
|
|||
{
|
||||
// migration 失敗
|
||||
vrm1Data = default;
|
||||
migration = new MigrationData(ex.Message, oldMeta);
|
||||
migration = new MigrationData(ex.ToString(), oldMeta);
|
||||
return null;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// その他のエラー
|
||||
vrm1Data = default;
|
||||
migration = new MigrationData(ex.Message, oldMeta);
|
||||
migration = new MigrationData(ex.ToString(), oldMeta);
|
||||
return null;
|
||||
}
|
||||
|
||||
byte[] debugCopy = null;
|
||||
if (VRMShaders.Symbols.VRM_DEVELOP)
|
||||
{
|
||||
// load 時の右手左手座標変換でバッファが破壊的変更されるので、コピーを作っている
|
||||
// load 時の右手左手座標変換でバッファが破壊的変更されるので、コピーを作っている
|
||||
debugCopy = migrated.Select(x => x).ToArray();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ namespace UniVRM10
|
|||
{
|
||||
/// <summary>
|
||||
/// preset 名の文字列から ExpressionPreset を確定させる。
|
||||
///
|
||||
///
|
||||
/// 0.x の特殊な挙動として、
|
||||
/// preset名が "unknown" の場合に、
|
||||
/// "name" を preset 名として解釈を試みる。
|
||||
|
|
@ -82,7 +82,7 @@ namespace UniVRM10
|
|||
}
|
||||
bind.Node = nodeIndex;
|
||||
bind.Index = morphTargetIndex;
|
||||
// https://github.com/vrm-c/vrm-specification/issues/209
|
||||
// https://github.com/vrm-c/vrm-specification/issues/209
|
||||
bind.Weight = weight * 0.01f;
|
||||
|
||||
yield return bind;
|
||||
|
|
@ -95,7 +95,7 @@ namespace UniVRM10
|
|||
public const string OUTLINE_COLOR_PROPERTY = "_OutlineColor";
|
||||
public const string SHADE_COLOR_PROPERTY = "_ShadeColor";
|
||||
|
||||
static UniGLTF.Extensions.VRMC_vrm.MaterialColorType ToMaterialType(string src)
|
||||
static UniGLTF.Extensions.VRMC_vrm.MaterialColorType? ToMaterialColorType(string src)
|
||||
{
|
||||
switch (src)
|
||||
{
|
||||
|
|
@ -115,17 +115,17 @@ namespace UniVRM10
|
|||
return UniGLTF.Extensions.VRMC_vrm.MaterialColorType.outlineColor;
|
||||
}
|
||||
|
||||
throw new NotImplementedException();
|
||||
return default;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// MaterialValue の仕様変更
|
||||
///
|
||||
///
|
||||
/// * MaterialColorBind
|
||||
/// * TextureTransformBind
|
||||
///
|
||||
///
|
||||
/// の2種類になった。
|
||||
///
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="gltf"></param>
|
||||
/// <param name="json"></param>
|
||||
|
|
@ -151,57 +151,70 @@ namespace UniVRM10
|
|||
}
|
||||
var propertyName = x["propertyName"].GetString();
|
||||
var targetValue = x["targetValue"].ArrayItems().Select(y => y.GetSingle()).ToArray();
|
||||
if (propertyName.EndsWith("_ST"))
|
||||
if (propertyName == "_MainTex_ST")
|
||||
{
|
||||
// VRM-0 は無変換
|
||||
var (scale, offset) = UniGLTF.TextureTransform.VerticalFlipScaleOffset(
|
||||
new UnityEngine.Vector2(targetValue[0], targetValue[1]),
|
||||
new UnityEngine.Vector2(targetValue[2], targetValue[3]));
|
||||
|
||||
expression.TextureTransformBinds.Add(new UniGLTF.Extensions.VRMC_vrm.TextureTransformBind
|
||||
if (!expression.TextureTransformBinds.Exists(bind => bind.Material == materialIndex))
|
||||
{
|
||||
Material = materialIndex,
|
||||
Scale = new float[] { scale.x, scale.y },
|
||||
Offset = new float[] { offset.x, offset.y }
|
||||
});
|
||||
expression.TextureTransformBinds.Add(new UniGLTF.Extensions.VRMC_vrm.TextureTransformBind
|
||||
{
|
||||
Material = materialIndex,
|
||||
Scale = new float[] {scale.x, scale.y},
|
||||
Offset = new float[] {offset.x, offset.y}
|
||||
});
|
||||
}
|
||||
}
|
||||
else if (propertyName.EndsWith("_ST_S"))
|
||||
else if (propertyName == "_MainTex_ST_S")
|
||||
{
|
||||
// VRM-0 は無変換
|
||||
var (scale, offset) = UniGLTF.TextureTransform.VerticalFlipScaleOffset(
|
||||
new UnityEngine.Vector2(targetValue[0], 1),
|
||||
new UnityEngine.Vector2(targetValue[2], 0));
|
||||
|
||||
expression.TextureTransformBinds.Add(new UniGLTF.Extensions.VRMC_vrm.TextureTransformBind
|
||||
if (!expression.TextureTransformBinds.Exists(bind => bind.Material == materialIndex))
|
||||
{
|
||||
Material = materialIndex,
|
||||
Scale = new float[] { scale.x, scale.y },
|
||||
Offset = new float[] { offset.x, offset.y }
|
||||
});
|
||||
expression.TextureTransformBinds.Add(new UniGLTF.Extensions.VRMC_vrm.TextureTransformBind
|
||||
{
|
||||
Material = materialIndex,
|
||||
Scale = new float[] {scale.x, scale.y},
|
||||
Offset = new float[] {offset.x, offset.y}
|
||||
});
|
||||
}
|
||||
}
|
||||
else if (propertyName.EndsWith("_ST_T"))
|
||||
else if (propertyName == "_MainTex_ST_T")
|
||||
{
|
||||
// VRM-0 は無変換
|
||||
var (scale, offset) = UniGLTF.TextureTransform.VerticalFlipScaleOffset(
|
||||
new UnityEngine.Vector2(1, targetValue[1]),
|
||||
new UnityEngine.Vector2(0, targetValue[3]));
|
||||
|
||||
expression.TextureTransformBinds.Add(new UniGLTF.Extensions.VRMC_vrm.TextureTransformBind
|
||||
if (!expression.TextureTransformBinds.Exists(bind => bind.Material == materialIndex))
|
||||
{
|
||||
Material = materialIndex,
|
||||
Scale = new float[] { scale.x, scale.y },
|
||||
Offset = new float[] { offset.x, offset.y }
|
||||
});
|
||||
expression.TextureTransformBinds.Add(new UniGLTF.Extensions.VRMC_vrm.TextureTransformBind
|
||||
{
|
||||
Material = materialIndex,
|
||||
Scale = new float[] {scale.x, scale.y},
|
||||
Offset = new float[] {offset.x, offset.y}
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// color
|
||||
expression.MaterialColorBinds.Add(new UniGLTF.Extensions.VRMC_vrm.MaterialColorBind
|
||||
var materialColorType = ToMaterialColorType(propertyName);
|
||||
if (materialColorType.HasValue)
|
||||
{
|
||||
Material = materialIndex,
|
||||
Type = ToMaterialType(propertyName),
|
||||
TargetValue = targetValue,
|
||||
});
|
||||
// color
|
||||
expression.MaterialColorBinds.Add(new UniGLTF.Extensions.VRMC_vrm.MaterialColorBind
|
||||
{
|
||||
Material = materialIndex,
|
||||
Type = materialColorType.Value,
|
||||
TargetValue = targetValue,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user