Skip to content

Commit bf67115

Browse files
authored
Merge pull request #1 from pikepikeid/Fix1
Fix parameter
2 parents 5046c9b + 63227c6 commit bf67115

1 file changed

Lines changed: 44 additions & 21 deletions

File tree

VRCFTPicoModule/Utils/Updater.cs

Lines changed: 44 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -111,17 +111,17 @@ private static void UpdateEye(float[] pShape)
111111
#region Eye
112112
SetParam(pShape, BlendShape.Index.EyeSquint_L, UnifiedExpressions.EyeSquintLeft);
113113
SetParam(pShape, BlendShape.Index.EyeSquint_R, UnifiedExpressions.EyeSquintRight);
114-
SetParam(pShape, BlendShape.Index.EyeWide_L, UnifiedExpressions.EyeWideLeft);
115-
SetParam(pShape, BlendShape.Index.EyeWide_R, UnifiedExpressions.EyeWideRight);
114+
SetParam(pShape[(int)BlendShape.Index.EyeWide_L] / 0.5f, UnifiedExpressions.EyeWideLeft); // 目を見開けるように補正
115+
SetParam(pShape[(int)BlendShape.Index.EyeWide_R] / 0.5f, UnifiedExpressions.EyeWideRight); // 目を見開けるように補正
116116
#endregion
117117
}
118118

119119
private void UpdateExpression(float[] pShape)
120120
{
121121
#region Jaw
122-
SetParam(pShape, BlendShape.Index.JawOpen, UnifiedExpressions.JawOpen);
123-
SetParam(pShape, BlendShape.Index.JawLeft, UnifiedExpressions.JawLeft);
124-
SetParam(pShape, BlendShape.Index.JawRight, UnifiedExpressions.JawRight);
122+
SetParam(pShape[(int)BlendShape.Index.JawOpen] / 0.8f, UnifiedExpressions.JawOpen); // 口を大きく開けるように補正
123+
SetParam(pShape[(int)BlendShape.Index.JawLeft] / 0.5f, UnifiedExpressions.JawLeft); // 口を開けたまま左に大きく動かせるように補正
124+
SetParam(pShape[(int)BlendShape.Index.JawRight] / 0.5f, UnifiedExpressions.JawRight); // 口を開けたまま右に大きく動かせるように補正
125125
SetParam(pShape, BlendShape.Index.JawForward, UnifiedExpressions.JawForward);
126126
SetParam(pShape, BlendShape.Index.MouthClose, UnifiedExpressions.MouthClosed);
127127
#endregion
@@ -162,13 +162,29 @@ private void UpdateExpression(float[] pShape)
162162
#endregion
163163

164164
#region Nose
165-
SetParam(pShape, BlendShape.Index.NoseSneer_L, UnifiedExpressions.NoseSneerLeft);
166-
SetParam(pShape, BlendShape.Index.NoseSneer_R, UnifiedExpressions.NoseSneerRight);
165+
var NoseSneerLeft = pShape[(int)BlendShape.Index.NoseSneer_L]; // 口が半開きになるのでNoseSneerを0.6まで動作しないように補正
166+
SetParam(pShape[(int)BlendShape.Index.NoseSneer_L] > 0.6f
167+
? NoseSneerLeft
168+
: 0f,
169+
UnifiedExpressions.NoseSneerLeft);
170+
var NoseSneerRight = pShape[(int)BlendShape.Index.NoseSneer_R]; // 口が半開きになるのでNoseSneerを0.6まで動作しないように補正
171+
SetParam(pShape[(int)BlendShape.Index.NoseSneer_R] > 0.6f
172+
? NoseSneerRight
173+
: 0f,
174+
UnifiedExpressions.NoseSneerLeft);
167175
#endregion
168176

169177
#region Mouth
170-
SetParam(pShape, BlendShape.Index.MouthUpperUp_L, UnifiedExpressions.MouthUpperUpLeft);
171-
SetParam(pShape, BlendShape.Index.MouthUpperUp_R, UnifiedExpressions.MouthUpperUpRight);
178+
var MouthUpperUpLeft = pShape[(int)BlendShape.Index.MouthUpperUp_L]; // MouthUpperUpをMouthPressが0.1まで入っているうちは動作しないように補正
179+
SetParam(pShape[(int)BlendShape.Index.MouthPress_L] < 0.1f
180+
? MouthUpperUpLeft / 0.8f
181+
: 0f,
182+
UnifiedExpressions.MouthUpperUpLeft);
183+
var MouthUpperUpRight = pShape[(int)BlendShape.Index.MouthUpperUp_R]; // MouthUpperUpをMouthPressが0.1まで入っているうちは動作しないように補正
184+
SetParam(pShape[(int)BlendShape.Index.MouthPress_R] < 0.1f
185+
? MouthUpperUpRight / 0.8f
186+
: 0f,
187+
UnifiedExpressions.MouthUpperUpRight);
172188
SetParam(pShape, BlendShape.Index.MouthLowerDown_L, UnifiedExpressions.MouthLowerDownLeft);
173189
SetParam(pShape, BlendShape.Index.MouthLowerDown_R, UnifiedExpressions.MouthLowerDownRight);
174190

@@ -190,17 +206,23 @@ private void UpdateExpression(float[] pShape)
190206

191207
SetParam(pShape, BlendShape.Index.MouthDimple_L, UnifiedExpressions.MouthDimpleLeft);
192208
SetParam(pShape, BlendShape.Index.MouthDimple_R, UnifiedExpressions.MouthDimpleRight);
193-
SetParam(pShape, BlendShape.Index.MouthLeft, UnifiedExpressions.MouthUpperLeft);
194-
SetParam(pShape, BlendShape.Index.MouthLeft, UnifiedExpressions.MouthLowerLeft);
195-
SetParam(pShape, BlendShape.Index.MouthRight, UnifiedExpressions.MouthUpperRight);
196-
SetParam(pShape, BlendShape.Index.MouthRight, UnifiedExpressions.MouthLowerRight);
209+
SetParam(pShape[(int)BlendShape.Index.MouthLeft] / 0.5f, UnifiedExpressions.MouthUpperLeft); // 口を閉じたまま左に大きく動かせるように補正
210+
SetParam(pShape[(int)BlendShape.Index.MouthLeft] / 0.5f, UnifiedExpressions.MouthLowerLeft); // 口を閉じたまま左に大きく動かせるように補正
211+
SetParam(pShape[(int)BlendShape.Index.MouthRight] / 0.5f, UnifiedExpressions.MouthUpperRight); // 口を閉じたまま右に大きく動かせるように補正
212+
SetParam(pShape[(int)BlendShape.Index.MouthRight] / 0.5f, UnifiedExpressions.MouthLowerRight); // 口を閉じたまま右に大きく動かせるように補正
197213
SetParam(pShape, BlendShape.Index.MouthPress_L, UnifiedExpressions.MouthPressLeft);
198214
SetParam(pShape, BlendShape.Index.MouthPress_R, UnifiedExpressions.MouthPressRight);
199215
SetParam(pShape, BlendShape.Index.MouthShrugLower, UnifiedExpressions.MouthRaiserLower);
200216
SetParam(pShape, BlendShape.Index.MouthShrugUpper, UnifiedExpressions.MouthRaiserUpper);
201217

202-
var mouthSmileLeft = pShape[(int)BlendShape.Index.MouthSmile_L] -
203-
pShape[(int)BlendShape.Index.MouthRollLower];
218+
// 0.5までしか来ない前提で線形補正
219+
var smileLeftRaw = pShape[(int)BlendShape.Index.MouthSmile_L] / 0.5f;
220+
var smileRightRaw = pShape[(int)BlendShape.Index.MouthSmile_R] / 0.5f;
221+
// 妙に偏るので強い方を優先してシンメトリー化
222+
var mouthSmileSym = Math.Max(smileLeftRaw, smileRightRaw);
223+
// 最終的に送る値
224+
var mouthSmileLeft = mouthSmileSym;
225+
var mouthSmileRight = mouthSmileSym;
204226
SetParam(pShape[(int)BlendShape.Index.MouthRollLower] < 0.2f
205227
? mouthSmileLeft
206228
: 0f,
@@ -209,18 +231,15 @@ private void UpdateExpression(float[] pShape)
209231
? mouthSmileLeft - pShape[(int)BlendShape.Index.MouthRollLower]
210232
: 0f,
211233
UnifiedExpressions.MouthCornerSlantLeft);
212-
213-
var mouthSmileRight = pShape[(int)BlendShape.Index.MouthSmile_R] -
214-
pShape[(int)BlendShape.Index.MouthRollLower];
215234
SetParam(pShape[(int)BlendShape.Index.MouthRollLower] < 0.2f
216235
? mouthSmileRight
217236
: 0f,
218237
UnifiedExpressions.MouthCornerPullRight);
219238
SetParam(pShape[(int)BlendShape.Index.MouthRollLower] < 0.2f
220-
? mouthSmileRight
239+
? mouthSmileRight - pShape[(int)BlendShape.Index.MouthRollLower]
221240
: 0f,
222241
UnifiedExpressions.MouthCornerSlantRight);
223-
242+
224243
SetParam(pShape, BlendShape.Index.MouthStretch_L, UnifiedExpressions.MouthStretchLeft);
225244
SetParam(pShape, BlendShape.Index.MouthStretch_R, UnifiedExpressions.MouthStretchRight);
226245
#endregion
@@ -259,7 +278,11 @@ private void UpdateExpression(float[] pShape)
259278
#endregion
260279

261280
#region Tongue
262-
SetParam(pShape, BlendShape.Index.TongueOut, UnifiedExpressions.TongueOut);
281+
// 気休め程度の誤爆防止
282+
SetParam(pShape[(int)BlendShape.Index.TongueOut] > 0.95f
283+
? pShape[(int)BlendShape.Index.TongueOut]
284+
: 0f,
285+
UnifiedExpressions.TongueOut);
263286
#endregion
264287
}
265288

0 commit comments

Comments
 (0)