Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

follow matcapFactor in material color binding #1820

Merged
merged 1 commit into from
Sep 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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