Skip to content

Commit 71e4a71

Browse files
authored
Merge pull request #2573 from ousttrue/fix/custom_material
_MainTex_ST の参照を修正
2 parents a6595a9 + ebe8ae6 commit 71e4a71

17 files changed

+1590
-489
lines changed

Assets/VRM10/Runtime/Components/Expression/MaterialValueBindingMerger.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ public static string GetProperty(MaterialColorType bindType)
2222
{
2323
switch (bindType)
2424
{
25-
// case MaterialBindType.UvOffset:
26-
// case MaterialBindType.UvScale:
27-
// return UV_PROPERTY;
28-
2925
case MaterialColorType.color:
3026
return COLOR_PROPERTY;
3127

Assets/VRM10/Runtime/Components/Expression/PreviewMaterialItem.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ public PreviewMaterialItem(Material material)
5656
Material = material;
5757

5858
// uv default value
59-
DefaultUVScaleOffset = material.GetVector(UV_PROPERTY);
59+
var s = material.mainTextureScale;
60+
var o = material.mainTextureOffset;
61+
DefaultUVScaleOffset = new(s.x, s.y, o.x, o.y);
6062
}
6163

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

80-
public static readonly string UV_PROPERTY = $"{MToon10Prop.BaseColorTexture.ToUnityShaderLabName()}_ST";
8182
public static readonly string COLOR_PROPERTY = MToon10Prop.BaseColorFactor.ToUnityShaderLabName();
8283
public static readonly string EMISSION_COLOR_PROPERTY = MToon10Prop.EmissiveFactor.ToUnityShaderLabName();
8384
public static readonly string RIM_COLOR_PROPERTY = MToon10Prop.ParametricRimColorFactor.ToUnityShaderLabName();
@@ -132,7 +133,8 @@ public void Clear()
132133
}
133134

134135
// clear UV
135-
Material.SetVector(UV_PROPERTY, DefaultUVScaleOffset);
136+
Material.mainTextureScale = new(DefaultUVScaleOffset.x, DefaultUVScaleOffset.y);
137+
Material.mainTextureOffset = new(DefaultUVScaleOffset.z, DefaultUVScaleOffset.w);
136138
}
137139

138140
/// <summary>
@@ -142,9 +144,12 @@ public void Clear()
142144
/// <param name="weight"></param>
143145
public void AddScaleOffset(Vector4 scaleOffset, float weight)
144146
{
145-
var value = Material.GetVector(UV_PROPERTY);
147+
var s = Material.mainTextureScale;
148+
var o = Material.mainTextureOffset;
149+
var value = new Vector4(s.x, s.y, o.x, o.y);
146150
value += (scaleOffset - DefaultUVScaleOffset) * weight;
147-
Material.SetColor(UV_PROPERTY, value);
151+
Material.mainTextureOffset = new(value.z, value.w);
152+
Material.mainTextureScale = new(value.x, value.y);
148153
}
149154
}
150155
}

Assets/VRM10/Runtime/Components/VrmAnimationInstance/IVrm10Animation.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ public interface IVrm10Animation : IDisposable
99
(INormalizedPoseProvider, ITPoseProvider) ControlRig { get; }
1010
IReadOnlyDictionary<ExpressionKey, Func<float>> ExpressionMap { get; }
1111
public void ShowBoxMan(bool enable);
12+
public void SetBoxManMaterial(Material material);
1213
LookAtInput? LookAt { get; }
1314
}
1415
}

Assets/VRM10/Runtime/Components/VrmAnimationInstance/Vrm10AnimationInstance.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ public void ShowBoxMan(bool enable)
1515
BoxMan.enabled = enable;
1616
}
1717

18+
public void SetBoxManMaterial(Material material)
19+
{
20+
BoxMan.material = material;
21+
}
22+
1823
public void Dispose()
1924
{
2025
if (Application.isPlaying)

Assets/VRM10/Runtime/Components/VrmAnimationInstance/Vrm10TPose.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,9 @@ public void Dispose()
6565
public void ShowBoxMan(bool enable)
6666
{
6767
}
68+
69+
public void SetBoxManMaterial(Material material)
70+
{
71+
}
6872
}
6973
}

Assets/VRM10_Samples/ClothSample/ClothViewer/Motions/BvhMotion.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ public void ShowBoxMan(bool enable)
5555
m_boxMan.enabled = enable;
5656
}
5757

58+
public void SetBoxManMaterial(Material material)
59+
{
60+
}
61+
5862
public void Dispose()
5963
{
6064
GameObject.Destroy(m_context.Root);

Assets/VRM10_Samples/VRM10Viewer/Assets.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)