國外著名購物網(wǎng)站排名關鍵詞排名零芯互聯(lián)排名
文章目錄
- 目的
- Blend Shape 逐頂點 多個混合思路
- Blender
- 3Ds max
- Unity 中使用
- Project
目的
拾遺,備份
Blend Shape 逐頂點 多個混合思路
blend shape 基于: vertex number, vertex sn 相同,才能正?;旌?、播放
也就是 vertex buffer 的頂點數(shù)量一樣,還有 triangles 的 index 要一致
這樣 blend shape 才能逐個頂點計算
計算公式:使用一張大佬整理的圖,大佬的文章:BlendShapes基礎與拓展練習(面捕與物體變形)
Blender
Shift+A 新建一個 sphere
選中
Tab 進入 Editor Mode,并且在 Data 頁簽屬性的 Shape Keys 添加對應的 blend shape 狀態(tài)
調整好每一個 Shape Keys (或是叫:blend shape) 的頂點位置
然后再 Object Mode 下,我們可以選中對應的 Shape Keys 然后調整 value 查看變形結果
最終我們嘗試 K幀動畫來查看 多個 shape keys 混合控制的情況
3Ds max
interlude _1 : working on Yui-chan’s face morphing. - 3Ds max 中的演示 二次元 臉部表情 FFD
Unity 中使用
先在 blender 導出 fbx
將 fbx 模型拖拽到 hierarchy
嘗試拖拉 inspector 中的 blend shape 拉桿,即可查看效果
所以我們寫腳本控制 blend shape 混合拉桿即可達到我們各種表情的混合控制
在原來 blendshape_1 基礎上在混合 blendshape_2
blendshape_1 和 blendshape_2 一起播放
然后可以嘗試看一下 blendshape_1 和 blendshape_2 不同速率的控制混合的情況
這里使用 pingpong 算法
下面是測試 csharp 腳本
// jave.lin 2023/10/07 測試 blend shapeusing System.Collections;
using UnityEngine;public class TestingBlendShape : MonoBehaviour
{public SkinnedMeshRenderer skinnedMeshRenderer;private int _BlendShape_1_IDX = -1;private int _BlendShape_2_IDX = -1;private IEnumerator _couroutine_blendShape1;private IEnumerator _couroutine_blendShape2;private IEnumerator _couroutine_pingpong;private void OnDestroy(){StopAllCoroutines();}private void Refresh(){if (skinnedMeshRenderer != null){_BlendShape_1_IDX = skinnedMeshRenderer.sharedMesh.GetBlendShapeIndex("BlendShape_1");_BlendShape_2_IDX = skinnedMeshRenderer.sharedMesh.GetBlendShapeIndex("BlendShape_2");}}public void ToBlendShape_1(){Refresh();if (_couroutine_blendShape1 != null){StopCoroutine(_couroutine_blendShape1);}StartCoroutine(_couroutine_blendShape1 = Play_ToBlendShape(_BlendShape_1_IDX, 100.0f));}public void ToBlendShape_2(){Refresh();if (_couroutine_blendShape2 != null){StopCoroutine(_couroutine_blendShape2);}StartCoroutine(_couroutine_blendShape2 = Play_ToBlendShape(_BlendShape_2_IDX, 100.0f));}public void ToBlendShape_1_2(){Refresh();if (_couroutine_blendShape1 != null){StopCoroutine(_couroutine_blendShape1);}StartCoroutine(_couroutine_blendShape1 = Play_ToBlendShape(_BlendShape_1_IDX, 100.0f));if (_couroutine_blendShape2 != null){StopCoroutine(_couroutine_blendShape2);}StartCoroutine(_couroutine_blendShape2 = Play_ToBlendShape(_BlendShape_2_IDX, 100.0f));}public void ToPingPong_BlendShape_1_2(){Refresh();if (_couroutine_pingpong != null){StopCoroutine(_couroutine_pingpong);}StartCoroutine(_couroutine_pingpong = PingPong_BlendShape());}public void StopAll(){StopAllCoroutines();}public void ResetAll(){if (skinnedMeshRenderer != null){var count = skinnedMeshRenderer.sharedMesh.blendShapeCount;for (int i = 0; i < count; i++){skinnedMeshRenderer.SetBlendShapeWeight(i, 0.0f);}}}private IEnumerator Play_ToBlendShape(int idx, float to_val){to_val = Mathf.Clamp(to_val, 0.0f, 100.0f);var start_val = skinnedMeshRenderer.GetBlendShapeWeight(idx);var cur_val = start_val;while (cur_val < to_val){cur_val = Mathf.MoveTowards(cur_val, to_val, (to_val - start_val) * Time.deltaTime);skinnedMeshRenderer.SetBlendShapeWeight(idx, cur_val);yield return null;}Debug.Log($"play to blend shape [{idx}] : [{to_val}] complete!");}private IEnumerator PingPong_BlendShape(){var now_time = Time.time;while (true){var _time = Time.time - now_time;var weight1 = Mathf.PingPong(_time * 200f, 100f);var weight2 = Mathf.PingPong(_time * 50f, 100f);skinnedMeshRenderer.SetBlendShapeWeight(_BlendShape_1_IDX, weight1);skinnedMeshRenderer.SetBlendShapeWeight(_BlendShape_2_IDX, weight2);yield return null;}}
}
Project
個人備份用
- blender 工程: TestingBlenderShapeKeys.blend
- unity 工程: TestingBlendShape_BRP_2020.3.37f1.rar
- 百人計劃-BlendShapes基礎(物體變形與面捕應用)
- google : how to implementing the blend shape in blender
- google : how to create shape keys animation in blender
- Shape Key / Blendshape Hacks to easily create expressions and actions for your avatar
- Blender 2.8 Shapekeys and Morphing
- How to Add Shape Keys in Blender
- 形態(tài)鍵
- 在Unity中實現(xiàn)BlendShape表情和骨骼動畫混合的實踐 - 講得挺不錯
- BlendShapes基礎與拓展練習(面捕與物體變形) - 講得挺不錯
- GDC2011: Fast and Efficient Facial Rigging
- GDC jeremy_ernst_fastandefficietfacialrigging.pdf
- 技術美術百人計劃-美術 3.5 BlendShape基礎 筆記
- 3.5 BlendShapes基礎
- 百人計劃-BlendShapes基礎(物體變形與面捕應用)
- 【技術美術百人計劃】美術 3.5 BlendShape基礎
- Unity通過導入器優(yōu)化動畫關鍵幀數(shù)據(jù) - 刪除僅僅只有 blend shape 的動畫的其他骨骼信息,優(yōu)化性能
- interlude _1 : working on Yui-chan’s face morphing. - 3Ds max 中的演示 二次元 臉部表情 FFD