國外著名購物網(wǎng)站排名關(guān)鍵詞排名零芯互聯(lián)排名
文章目錄
- 目的
- Blend Shape 逐頂點(diǎn) 多個(gè)混合思路
- Blender
- 3Ds max
- Unity 中使用
- Project
目的
拾遺,備份
Blend Shape 逐頂點(diǎn) 多個(gè)混合思路
blend shape 基于: vertex number, vertex sn 相同,才能正?;旌?、播放
也就是 vertex buffer 的頂點(diǎn)數(shù)量一樣,還有 triangles 的 index 要一致
這樣 blend shape 才能逐個(gè)頂點(diǎn)計(jì)算
計(jì)算公式:使用一張大佬整理的圖,大佬的文章:BlendShapes基礎(chǔ)與拓展練習(xí)(面捕與物體變形)
Blender
Shift+A 新建一個(gè) sphere
選中
Tab 進(jìn)入 Editor Mode,并且在 Data 頁簽屬性的 Shape Keys 添加對(duì)應(yīng)的 blend shape 狀態(tài)
調(diào)整好每一個(gè) Shape Keys (或是叫:blend shape) 的頂點(diǎn)位置
然后再 Object Mode 下,我們可以選中對(duì)應(yīng)的 Shape Keys 然后調(diào)整 value 查看變形結(jié)果
最終我們嘗試 K幀動(dòng)畫來查看 多個(gè) shape keys 混合控制的情況
3Ds max
interlude _1 : working on Yui-chan’s face morphing. - 3Ds max 中的演示 二次元 臉部表情 FFD
Unity 中使用
先在 blender 導(dǎo)出 fbx
將 fbx 模型拖拽到 hierarchy
嘗試拖拉 inspector 中的 blend shape 拉桿,即可查看效果
所以我們寫腳本控制 blend shape 混合拉桿即可達(dá)到我們各種表情的混合控制
在原來 blendshape_1 基礎(chǔ)上在混合 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
個(gè)人備份用
- blender 工程: TestingBlenderShapeKeys.blend
- unity 工程: TestingBlendShape_BRP_2020.3.37f1.rar
- 百人計(jì)劃-BlendShapes基礎(chǔ)(物體變形與面捕應(yīng)用)
- 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中實(shí)現(xiàn)BlendShape表情和骨骼動(dòng)畫混合的實(shí)踐 - 講得挺不錯(cuò)
- BlendShapes基礎(chǔ)與拓展練習(xí)(面捕與物體變形) - 講得挺不錯(cuò)
- GDC2011: Fast and Efficient Facial Rigging
- GDC jeremy_ernst_fastandefficietfacialrigging.pdf
- 技術(shù)美術(shù)百人計(jì)劃-美術(shù) 3.5 BlendShape基礎(chǔ) 筆記
- 3.5 BlendShapes基礎(chǔ)
- 百人計(jì)劃-BlendShapes基礎(chǔ)(物體變形與面捕應(yīng)用)
- 【技術(shù)美術(shù)百人計(jì)劃】美術(shù) 3.5 BlendShape基礎(chǔ)
- Unity通過導(dǎo)入器優(yōu)化動(dòng)畫關(guān)鍵幀數(shù)據(jù) - 刪除僅僅只有 blend shape 的動(dòng)畫的其他骨骼信息,優(yōu)化性能
- interlude _1 : working on Yui-chan’s face morphing. - 3Ds max 中的演示 二次元 臉部表情 FFD