add override facial

This commit is contained in:
CroakFang
2023-02-26 14:48:37 +08:00
parent 90a3579d1f
commit f1dd2a9725
15 changed files with 300 additions and 16 deletions
+2 -1
View File
@@ -248,7 +248,6 @@ public class ManifestDB
Debug.LogError("ReadLineError");
return null;
}
}
else
{
@@ -290,6 +289,8 @@ public class ManifestDB
else
{
Debug.LogError("Download Manifest Failed :" + www.error);
callback?.Invoke($"Download Manifest Failed :{www.error},Update aborted");
yield break;
}
}
+5
View File
@@ -31,6 +31,7 @@ public class UmaContainer : MonoBehaviour
[Header("Face")]
public FaceDrivenKeyTarget FaceDrivenKeyTarget;
public FaceEmotionKeyTarget FaceEmotionKeyTarget;
public FaceOverrideData FaceOverrideData;
public GameObject HeadBone;
public GameObject TrackTarget;
public float EyeHeight;
@@ -71,6 +72,10 @@ public class UmaContainer : MonoBehaviour
public List<CySpringDataContainer> cySpringDataContainers;
public GameObject PhysicsContainer;
public float BodyScale = 1;
[Header("Other")]
public CharaShaderEffectData ShaderEffectData;
public void Initialize()
{
TrackTarget = Camera.main.gameObject;
+11 -2
View File
@@ -347,9 +347,11 @@ public class UmaViewerBuilder : MonoBehaviour
var firsehead = CurrentUMAContainer.Head;
var faceDriven = firsehead.GetComponent<AssetHolder>()._assetTable["facial_target"] as FaceDrivenKeyTarget;
var earDriven = firsehead.GetComponent<AssetHolder>()._assetTable["ear_target"] as DrivenKeyTarget;
var faceOverride = firsehead.GetComponent<AssetHolder>()._assetTable["face_override"] as FaceOverrideData;
faceDriven._earTarget = earDriven._targetFaces;
CurrentUMAContainer.FaceDrivenKeyTarget = faceDriven;
CurrentUMAContainer.FaceDrivenKeyTarget.Container = CurrentUMAContainer;
CurrentUMAContainer.FaceOverrideData = faceOverride;
faceDriven.DrivenKeyLocator = locator.transform;
faceDriven.Initialize(firsehead.GetComponentsInChildren<Transform>().ToList());
@@ -633,9 +635,11 @@ public class UmaViewerBuilder : MonoBehaviour
var firsehead = CurrentUMAContainer.Head;
var faceDriven = firsehead.GetComponent<AssetHolder>()._assetTable["facial_target"] as FaceDrivenKeyTarget;
var earDriven = firsehead.GetComponent<AssetHolder>()._assetTable["ear_target"] as DrivenKeyTarget;
var faceOverride = firsehead.GetComponent<AssetHolder>()._assetTable["face_override"] as FaceOverrideData;
faceDriven._earTarget = earDriven._targetFaces;
CurrentUMAContainer.FaceDrivenKeyTarget = faceDriven;
CurrentUMAContainer.FaceDrivenKeyTarget.Container = CurrentUMAContainer;
CurrentUMAContainer.FaceOverrideData = faceOverride;
faceDriven.DrivenKeyLocator = locator.transform;
faceDriven.Initialize(firsehead.GetComponentsInChildren<Transform>().ToList());
@@ -777,8 +781,6 @@ public class UmaViewerBuilder : MonoBehaviour
a.CostumeId = "00";
}
});//fill empty
}
//Use CriWare Library
@@ -1394,6 +1396,13 @@ public class UmaViewerBuilder : MonoBehaviour
}
}
}
//shader effect
CurrentUMAContainer.ShaderEffectData = head.GetComponent<AssetHolder>()._assetTable["chara_shader_effect"] as CharaShaderEffectData;
if (CurrentUMAContainer.ShaderEffectData)
{
CurrentUMAContainer.ShaderEffectData.Initialize();
}
}
private void LoadHair(GameObject go)
@@ -0,0 +1,44 @@
using System;
using UnityEngine;
namespace Gallop
{
[Serializable]
public class CharaShaderEffectData : ScriptableObject
{
[SerializeField]
private SettingData[] _settingDataArray;
[Serializable]
public class SettingData
{
public EffectType Type;
public Material TargetMaterial;
public int[] ParamArray;
public AnimationCurve[] ParamCurveArray;
}
public enum EffectType
{
UVScrollEmissive = 0,
ReflectionMap = 1
}
public void Initialize()
{
foreach(var settingData in _settingDataArray)
{
if (settingData.TargetMaterial)
{
var mat = settingData.TargetMaterial;
if (settingData.Type == EffectType.UVScrollEmissive)
{
var p = settingData.ParamArray;
mat.SetVector("_UVEmissiveScroll", new Vector4(p[0], p[1], p[2],p[3]));
mat.SetVector("_UVEmissiveRange", new Vector4(p[4], p[5], p[6], p[7]));
}
}
}
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c646073cb80c388489345c22e65f9425
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,9 @@
using UnityEngine;
namespace Gallop
{
public class CharaTransformProcessData : ScriptableObject
{
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ad24e221a99993948ae4740c38a0a377
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -35,6 +35,8 @@ namespace Gallop
Dictionary<Transform, Vector3> RotationRecorder = new Dictionary<Transform, Vector3>();
Dictionary<Particle, Vector3> ParticleRecorder = new Dictionary<Particle, Vector3>();
List<FacialMorph> leftEyeMorph = new List<FacialMorph>();
List<FacialMorph> rightEyeMorph = new List<FacialMorph>();
public void Initialize(List<Transform> objs)
{
Objs = objs;
@@ -53,6 +55,7 @@ namespace Gallop
for (int j = 0; j < _earTarget[i]._faceGroupInfo.Count; j++)
{
FacialMorph morph = new FacialMorph();
morph.index = i;
morph.direction = j > 0;
morph.name = "Ear_" + i + "_" + (morph.direction ? "L" : "R");
morph.tag = Enum.GetName(typeof(EarType), i);
@@ -84,6 +87,7 @@ namespace Gallop
for (int j = 0; j < _eyebrowTarget[i]._faceGroupInfo.Count; j++)
{
FacialMorph morph = new FacialMorph();
morph.index = i;
morph.direction = j > 0;
morph.name = "EyeBrow_" + i + "_" + (morph.direction ? "L" : "R");
morph.tag = Enum.GetName(typeof(LiveTimelineDefine.FacialEyebrowId), i);
@@ -109,6 +113,7 @@ namespace Gallop
for (int j = 0; j < _eyeTarget[i]._faceGroupInfo.Count; j++)
{
FacialMorph morph = new FacialMorph();
morph.index = i;
morph.direction = j > 0;
morph.name = "Eye_" + i + "_" + (morph.direction ? "L" : "R");
morph.tag = Enum.GetName(typeof(LiveTimelineDefine.FacialEyeId), i);
@@ -134,7 +139,11 @@ namespace Gallop
if (morph.direction) LeftEyeYrange = morph;
else RightEyeYrange = morph;
}
else
{
if (morph.direction) leftEyeMorph.Add(morph);
else rightEyeMorph.Add(morph);
}
EyeMorphs.Add(morph);
}
}
@@ -145,6 +154,7 @@ namespace Gallop
for (int j = 0; j < _mouthTarget[i]._faceGroupInfo.Count; j++)
{
FacialMorph morph = new FacialMorph();
morph.index = i;
morph.direction = j > 0;
morph.name = "Mouth_" + i + "_" + j;
morph.tag = Enum.GetName(typeof(LiveTimelineDefine.FacialMouthId), i);
@@ -443,6 +453,7 @@ namespace Gallop
public void FacialResetAll()
{
FacialReset(BaseLEarMorph.trsArray);
FacialReset(BaseREarMorph.trsArray);
FacialReset(BaseLEyeBrowMorph.trsArray);
@@ -451,6 +462,10 @@ namespace Gallop
FacialReset(BaseREyeMorph.trsArray);
FacialReset(BaseMouthMorph.trsArray);
ApplyRotation();
if (Container.FaceOverrideData)
{
OverrideFace(Container.FaceOverrideData);
}
}
public void FacialReset(List<TrsArray> trsArrays)
@@ -565,6 +580,59 @@ namespace Gallop
ProcessLocator();
ChangeMorph();
}
public void OverrideFace(FaceOverrideData overrideData)
{
Action<List<FacialMorph>, FaceOverrideReplaceDataSet[]> action = delegate (List<FacialMorph> morphs, FaceOverrideReplaceDataSet[] datalist)
{
foreach (var data in datalist)
{
if (data.IsOnlyBaseReplace)
{
if (morphs.Find(m => m.weight > 0) == null)
{
GetMorphByType(morphs, data.BaseReplaceFaceType).weight = 1;
}
else
{
GetMorphByType(morphs, data.BaseReplaceFaceType).weight = 0;
}
}
foreach (var arr in data.DataArray)
{
bool changed = false;
foreach(var src in arr.SrcArray)
{
if (src == LiveTimelineDefine.FacialEyeId.Base) continue;
var srcmorph = GetMorphByType(morphs, src);
if (srcmorph.weight > 0 && !changed)
{
changed = true;
foreach (var dst in arr.DstArray)
{
GetMorphByType(morphs, dst.Index).weight = Mathf.Lerp(0, dst.Weight, srcmorph.weight);
}
}
srcmorph.weight = 0;
}
}
}
};
if (overrideData.IsBothEyesSetting)
{
action.Invoke(leftEyeMorph, overrideData.FaceOverrideArray);
action.Invoke(rightEyeMorph, overrideData.FaceOverrideArray);
}
}
public FacialMorph GetMorphByType(List<FacialMorph> morphs, LiveTimelineDefine.FacialEyeId Type)
{
return morphs.Find(m => m.index == (int)Type);
}
}
}
@@ -0,0 +1,23 @@
using System;
using UnityEngine;
namespace Gallop
{
[Serializable]
public class FaceOverrideData : ScriptableObject
{
private readonly string[] OverrideTypeText;
public bool IsBothEyesSetting;
public bool IsDisableEyeBlink;
public FaceOverrideReplaceDataSet[] FaceOverrideArray;
public enum OverrideType
{
Invalid = -1,
RightEye = 0,
LeftEye = 1,
Max = 2
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8f48d3d928b991543b1454bfaabf7259
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -10,6 +10,7 @@ namespace Gallop
[System.Serializable]
public class FacialMorph
{
public int index;
public string name;
public string tag = "";
public bool direction;
+37 -12
View File
@@ -1,9 +1,10 @@
using Unity;
using System.Collections.Generic;
using UnityEngine;
using static DynamicBone;
using System;
using Object = UnityEngine.Object;
[System.Serializable]
[Serializable]
public class AssetTable
{
public Object this[string key]
@@ -26,7 +27,7 @@ public class AssetTable
}
[System.Serializable]
[Serializable]
public class AssetTableValue
{
public float this[string key]
@@ -48,21 +49,21 @@ public class AssetTableValue
}
[System.Serializable]
[Serializable]
public class StringObjectPair
{
public string Key;
public Object Value;
}
[System.Serializable]
[Serializable]
public class StringValuePair
{
public string Key;
public float Value;
}
[System.Serializable]
[Serializable]
public class TrsArray
{
public string _path;
@@ -82,38 +83,38 @@ public class TrsArray
}
}
[System.Serializable]
[Serializable]
public class FaceGroupInfo
{
public List<TrsArray> _trsArray;
}
[System.Serializable]
[Serializable]
public class EyeTarget
{
public List<FaceGroupInfo> _faceGroupInfo;
}
[System.Serializable]
[Serializable]
public class EyebrowTarget
{
public List<FaceGroupInfo> _faceGroupInfo;
}
[System.Serializable]
[Serializable]
public class MouthTarget
{
public List<FaceGroupInfo> _faceGroupInfo;
}
[System.Serializable]
[Serializable]
public class TargetInfomation
{
public List<FaceGroupInfo> _faceGroupInfo;
}
[System.Serializable]
[Serializable]
public class ConnectedBoneData
{
public string Bone1;
@@ -121,3 +122,27 @@ public class ConnectedBoneData
public float Intensity;
public bool IsFold;
}
[Serializable]
public class FaceOverrideReplaceDataSet
{
public bool IsOnlyBaseReplace;
public Gallop.Live.Cutt.LiveTimelineDefine.FacialEyeId BaseReplaceFaceType;
public FaceOverrideReplaceData[] DataArray;
}
[Serializable]
public class FaceOverrideReplaceData
{
public Gallop.Live.Cutt.LiveTimelineDefine.FacialEyeId[] SrcArray;
public FaceOverrideElement[] DstArray;
}
[Serializable]
public class FaceOverrideElement
{
public Gallop.Live.Cutt.LiveTimelineDefine.FacialEyeId Index;
public float Weight;
}
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 18af0e9423bc204488746a0cfbdf8a99
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,47 @@
using System;
using UnityEngine;
namespace IK
{
public class IKCollisionData : ScriptableObject
{
public Parameter[] ParameterArray;
public bool IsHeightScale;
public struct RuntimeParameter
{
public Parameter.CollisionType Type;
public Vector3 Offset;
public bool IsBodyScale;
public float Param1;
public float Radius { get; }
}
[Serializable]
public class Parameter
{
public CollisionType Type;
public string LinkBoneName;
public Vector3 Offset;
public Scene SceneType;
public float Param1;
public enum CollisionType
{
Sphere = 0
}
public enum Scene
{
Event = 1,
Live = 2,
All = 65535
}
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4a1187d9f807ff846bde338c226f3450
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: