Skip to content

Commit

Permalink
Merge pull request #1820 from Santarh/matcapFactorFix
Browse files Browse the repository at this point in the history
follow matcapFactor in material color binding
  • Loading branch information
ousttrue authored Sep 21, 2022
2 parents b534d26 + ec627fb commit d54a3d5
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using UniGLTF.Extensions.VRMC_vrm;
using UnityEngine;
using VRMShaders.VRM10.MToon10.Runtime;

namespace UniVRM10
{
Expand All @@ -10,11 +11,12 @@ namespace UniVRM10
///
internal sealed class MaterialValueBindingMerger
{
public const string COLOR_PROPERTY = "_Color";
public const string EMISSION_COLOR_PROPERTY = "_EmissionColor";
public const string RIM_COLOR_PROPERTY = "_RimColor";
public const string OUTLINE_COLOR_PROPERTY = "_OutlineColor";
public const string SHADE_COLOR_PROPERTY = "_ShadeColor";
private static readonly string COLOR_PROPERTY = MToon10Prop.BaseColorFactor.ToUnityShaderLabName();
private static readonly string EMISSION_COLOR_PROPERTY = MToon10Prop.EmissiveFactor.ToUnityShaderLabName();
private static readonly string RIM_COLOR_PROPERTY = MToon10Prop.ParametricRimColorFactor.ToUnityShaderLabName();
private static readonly string OUTLINE_COLOR_PROPERTY = MToon10Prop.OutlineColorFactor.ToUnityShaderLabName();
private static readonly string SHADE_COLOR_PROPERTY = MToon10Prop.ShadeColorFactor.ToUnityShaderLabName();
private static readonly string MATCAP_COLOR_PROPERTY = MToon10Prop.MatcapColorFactor.ToUnityShaderLabName();

public static string GetProperty(MaterialColorType bindType)
{
Expand All @@ -38,6 +40,9 @@ public static string GetProperty(MaterialColorType bindType)

case MaterialColorType.outlineColor:
return OUTLINE_COLOR_PROPERTY;

case MaterialColorType.matcapColor:
return MATCAP_COLOR_PROPERTY;
}

throw new NotImplementedException();
Expand Down
52 changes: 31 additions & 21 deletions Assets/VRM10/Runtime/Components/Expression/PreviewMaterialItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using UnityEngine;
using UniGLTF.Extensions.VRMC_vrm;
using VRMShaders.VRM10.MToon10.Runtime;


namespace UniVRM10
Expand Down Expand Up @@ -76,30 +77,39 @@ public void RestoreInitialValues()
}
}

public const string UV_PROPERTY = "_MainTex_ST";
public const string COLOR_PROPERTY = "_Color";
public const string EMISSION_COLOR_PROPERTY = "_EmissionColor";
public const string RIM_COLOR_PROPERTY = "_RimColor";
public const string OUTLINE_COLOR_PROPERTY = "_OutlineColor";
public const string SHADE_COLOR_PROPERTY = "_ShadeColor";
public static readonly string UV_PROPERTY = $"{MToon10Prop.BaseColorTexture.ToUnityShaderLabName()}_ST";
public static readonly string COLOR_PROPERTY = MToon10Prop.BaseColorFactor.ToUnityShaderLabName();
public static readonly string EMISSION_COLOR_PROPERTY = MToon10Prop.EmissiveFactor.ToUnityShaderLabName();
public static readonly string RIM_COLOR_PROPERTY = MToon10Prop.ParametricRimColorFactor.ToUnityShaderLabName();
public static readonly string OUTLINE_COLOR_PROPERTY = MToon10Prop.OutlineColorFactor.ToUnityShaderLabName();
public static readonly string SHADE_COLOR_PROPERTY = MToon10Prop.ShadeColorFactor.ToUnityShaderLabName();
public static readonly string MATCAP_COLOR_PROPERTY = MToon10Prop.MatcapColorFactor.ToUnityShaderLabName();

public static MaterialColorType GetBindType(string property)
{
switch (property)
if (property == COLOR_PROPERTY)
{
case COLOR_PROPERTY:
return MaterialColorType.color;

case EMISSION_COLOR_PROPERTY:
return MaterialColorType.emissionColor;

case RIM_COLOR_PROPERTY:
return MaterialColorType.rimColor;

case SHADE_COLOR_PROPERTY:
return MaterialColorType.shadeColor;

case OUTLINE_COLOR_PROPERTY:
return MaterialColorType.outlineColor;
return MaterialColorType.color;
}
if (property == EMISSION_COLOR_PROPERTY)
{
return MaterialColorType.emissionColor;
}
if (property == RIM_COLOR_PROPERTY)
{
return MaterialColorType.rimColor;
}
if (property == OUTLINE_COLOR_PROPERTY)
{
return MaterialColorType.outlineColor;
}
if (property == SHADE_COLOR_PROPERTY)
{
return MaterialColorType.shadeColor;
}
if (property == MATCAP_COLOR_PROPERTY)
{
return MaterialColorType.matcapColor;
}

throw new NotImplementedException();
Expand Down

0 comments on commit d54a3d5

Please sign in to comment.