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

_MainTex_ST の参照を修正 #2573

Merged
merged 6 commits into from
Feb 4, 2025
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 @@ -22,10 +22,6 @@ public static string GetProperty(MaterialColorType bindType)
{
switch (bindType)
{
// case MaterialBindType.UvOffset:
// case MaterialBindType.UvScale:
// return UV_PROPERTY;

case MaterialColorType.color:
return COLOR_PROPERTY;

Expand Down
15 changes: 10 additions & 5 deletions Assets/VRM10/Runtime/Components/Expression/PreviewMaterialItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ public PreviewMaterialItem(Material material)
Material = material;

// uv default value
DefaultUVScaleOffset = material.GetVector(UV_PROPERTY);
var s = material.mainTextureScale;
var o = material.mainTextureOffset;
DefaultUVScaleOffset = new(s.x, s.y, o.x, o.y);
}

public Dictionary<UniGLTF.Extensions.VRMC_vrm.MaterialColorType, PropItem> PropMap = new Dictionary<UniGLTF.Extensions.VRMC_vrm.MaterialColorType, PropItem>();
Expand All @@ -77,7 +79,6 @@ public void RestoreInitialValues()
}
}

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();
Expand Down Expand Up @@ -132,7 +133,8 @@ public void Clear()
}

// clear UV
Material.SetVector(UV_PROPERTY, DefaultUVScaleOffset);
Material.mainTextureScale = new(DefaultUVScaleOffset.x, DefaultUVScaleOffset.y);
Material.mainTextureOffset = new(DefaultUVScaleOffset.z, DefaultUVScaleOffset.w);
}

/// <summary>
Expand All @@ -142,9 +144,12 @@ public void Clear()
/// <param name="weight"></param>
public void AddScaleOffset(Vector4 scaleOffset, float weight)
{
var value = Material.GetVector(UV_PROPERTY);
var s = Material.mainTextureScale;
var o = Material.mainTextureOffset;
var value = new Vector4(s.x, s.y, o.x, o.y);
value += (scaleOffset - DefaultUVScaleOffset) * weight;
Material.SetColor(UV_PROPERTY, value);
Material.mainTextureOffset = new(value.z, value.w);
Material.mainTextureScale = new(value.x, value.y);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public interface IVrm10Animation : IDisposable
(INormalizedPoseProvider, ITPoseProvider) ControlRig { get; }
IReadOnlyDictionary<ExpressionKey, Func<float>> ExpressionMap { get; }
public void ShowBoxMan(bool enable);
public void SetBoxManMaterial(Material material);
LookAtInput? LookAt { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ public void ShowBoxMan(bool enable)
BoxMan.enabled = enable;
}

public void SetBoxManMaterial(Material material)
{
BoxMan.material = material;
}

public void Dispose()
{
if (Application.isPlaying)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,9 @@ public void Dispose()
public void ShowBoxMan(bool enable)
{
}

public void SetBoxManMaterial(Material material)
{
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ public void ShowBoxMan(bool enable)
m_boxMan.enabled = enable;
}

public void SetBoxManMaterial(Material material)
{
}

public void Dispose()
{
GameObject.Destroy(m_context.Root);
Expand Down
8 changes: 8 additions & 0 deletions Assets/VRM10_Samples/VRM10Viewer/Assets.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading