AnimationBlending

Animation

Written with StackEdit.

Code Structure for Animation

struct JointPose {
	Quaternion m_rot; //q
	Vector3 m_trans; //t
	F32 m_scale; //s
}

struct AnimationSample{
	JointPose* m_aJointPose;
}

struct AnimationClip{
	Skeleton* m_pSkeleton; //指向骨骼
	F32 m_framePerSecond;
	U32 m_frameCount; 
	AnimationSample* m_aSamples; //每帧的数据
	bool m_isLooping;
}

len(m_aSamples) is m_frameCount+1 when m_isLooping == False, else m_frameCount;

Animation Retargeting

  • Animation is usually compatible with only one skeleton
    • But some closely related skeletons can use these animations
    • Only if engine supports ignoring animation channels that cannot be found in skeleton being animated
    • Advanced research on retargeting animations on totally different skeletons

Continuous Channel Functions

  • According SQT data format for each sample,
    • 10 scalar-valued functions per joint
    • the time continuous functions per joint is a channel
    • channel functions should be smooth and continuous across the entire animation clip
    • many engines LERP bettwen the samples, making it piecewise linear approximations to the underlying continuous functions

Metachannels

  • channels that do not have to do with posing
    • but used to be synchronized with the animation
  • event trigger channel
    • sound, particle effects and so on
  • animated locator
    • special joint
    • such as camera position, orientation, fov…
  • texture coordinates scrolling
  • texture animation
  • animated parameter
    • material
    • lighting

Skinning and Matrix Palette Generation

Attaching the vertices of a 3D mesh to a posed skeleton is call skinning

Per-Vertex Skinning Information

  • a skinned mesh is attached to a skeleton by means of its vertices.
  • each vertex can be attached to one or multiple joints
    • if multiple, the position becomes weighted average of the positions that it would have assumed had it bound to each joint independently
    • so each vertex information should including
      • the index of joints to which it is bound
      • the weighting factor for each joint
    • the maximal no of bound joints is usually 4
  • data structure:
    struct Skinned Vertex{
    	float m_position[3];
    	float m_normal[3];
    	float m_u, m_v; //u,v for texture cordinates
    	U8 m_jointIndex[4];
    	float m_jointWeight[3];
    }
    

Mathematics of Skinning

  • Skinning matrix: transform vertices from original position in bind pose to current position that correspond to the current pose.
    • always in model space
  • One joint example
    • B j → M B_{j \to M} BjM : bind pose of the joint j in model space
    • C j → M C_{j \to M} CjM: current pose of the joint in the model space
    • V j V_j Vj: joint space position of current vertex
    • Kj = (B j → M _{j \to M} jM)-1C j → M _{j \to M} jM
    • V M C ^C_M MC = V j V_j Vj C j → M C_{j \to M} CjM
      = V M B ( B j → M ) − 1 C j → M V_M^B(B_{j \to M})^{-1}C_{j \to M} VMB(BjM)1CjM
      = V M B ^B_M MBK j _{j} j
    • usually B j → M B_{j \to M} BjM is cached in skeleton, C j → M C{j \to M} CjM calculated using Local Joint Space to Model Space Equation :
      P j → M = Π i = j 0 P i → p ( i ) P_{j \to M} = \Pi_{i=j}^0 P_{i \to p(i)} PjM=Πi=j0Pip(i)
  • Multiple Joints:
    • for each pose, (K1, …, Kj) is called matrix palette
    • K j i K_{j_i} Kji is transform matrix for joint i
    • V M C ^C_M MC = Σ i = 0 N − 1 \Sigma_{i=0}^{N-1} Σi=0N1 wiV M B ^B_M MBK j i _{j_i} ji

Animation Blending

more than 1 animation clip contribute to the final pose of character

LERP Blending

  • (PLERP)j = LERP((PA)j, (PB)j, β \beta β) = (1 - β \beta β)(PA)j + β \beta β(PB)j
  • P s k e l L E R P _{skel}^{LERP} skelLERP = { (PLERP)j } | j = 0 N − 1   ^{N-1}_{j=0}~ j=0N1 
  • β \beta β is called the blending percentage or blend factor
  • SQT format data is easy to blend, not as 4X4 matrix
  • T and S: vector LERP, Q: LERP or SLERP
  • independently on each joint, parallel calculated

Applications of LERP Blending

  • Temporal Blending
    • finding intermediate poses between sampled poses
  • Motion continuity: Cross Fading
    • clip transitions may pop, not smooth
    • C0 continuity: path trace smooth
    • C1 continuity: velocity smooth
    • C2 continuity: second derivatives of the motion path smooth
    • C3 and higher …
    • LERP blending used in transitions to achieve C0 or C1 continuity is called cross fading
    • overlap time, β \beta β from 0 to 1
    • types of cross fading
      • smooth transition: Clip A and B play simultaneously, β \beta β changes over time
      • Frozen transition: A stops and B gradually takes over
        • usually used in unrelated clips
      • blend factor β \beta β functions
        • linear, cubic
        • ease-in, ease-out
      • Core poses
        • every clip starts and ends in these poses
        • C0 continuity: ensure two core poses match
        • C1 continuity: authoring a single smooth animation into A end and B start

Directional Locomotion

pivotal movement: always face to where it turns
targeted movement: moving sideways, backward, forward, keeping its face to a target

  • targeted movement
    • forward, strafe left, strafe right
    • LERP blend between two adjacent clips, β \beta β according to angle
    • backward not included because of legs crossing each other
      • one feasible approach: use to hemispherical blends, one for forward and another for backward; explicit transition animation is played between hemisphere switch
  • pivotal movement
    • always play forward clips
    • slightly leaning sideways when turning
    • author three clips: move straight forward, extremely left turn, extremely right turn
    • LERP blending between them to create desired turn pose

Complex LERP Blends

prepackage certain commonly used blends for ease of use

  • generalized one-dimensional LERP blending
    From game engine architecture second edition

  • Simple two-dimensional LERP blending

    • (bx, by), 4 corner clips A, B, C, D
    • two steps
      • use bx to blend between A and B to BAB, C and D to BCD
      • use by to blend BAB and BCD
        在这里插入图片描述
  • Triangular two-dimensional LERP blending

    • blend between arbitrary number of clips positioned at arbitrary positions
    • (PLERP)j = α \alpha α(P0)j + β \beta β(P1)j + γ \gamma γ(P2)j
    • α \alpha α + β \beta β + γ \gamma γ = 1
    • barycentric coordinates b
      • b = α \alpha αb0 + β \beta βb1 + γ \gamma γb2 在这里插入图片描述
  • generalized two-dimensional LERP blending

    • Delaunay triangul在这里插入图片描述

Partial-Skeleton Blending

wave hands when walking, a partial blocking is required

  • the set of blending percentages: { β \beta βj}| j = 0 N − 1 ^{N-1}_{j=0} j=0N1
  • in LERP, β \beta βj=0 can be used to mask out certain joints
  • for the walking-wave-hands example
    • mask out joints on except right arm
  • problems:
    • abrupt change: gradually change β \beta β instead of abrupt change
    • looking not natural because human body movements are never independent, but partial-skeleton blending makes the two partial movements independent of each other
      • in the walking-wave-hands example, human should look slightly different when run/walk/stand waving hands
      • so we turn to additive blending

Additive Blending

  • difference clip: difference between two clips
    • also called additive animation clip
  • D = S - R
    • D: difference clip, S: source, R: reference
    • R + β \beta βD: partial add
      * S ˋ = R ˋ + D \grave{S} = \grave{R} + D Sˋ=Rˋ+D can create new clip, with S appearing naturally blended on R ˋ \grave{R} Rˋ (for example ,run is R, walk is R ˋ \grave{R} Rˋ, S is run tiredly, then S ˋ \grave{S} Sˋ is walking tiredly, D is tired)
  • Mathematical Formulation
    • D j = S j R j − 1 D_j = S_jR_j^{-1} Dj=SjRj1, for joint j
      • D j D_j Dj is difference pose
      • R j R_j Rj is reference pose
      • R j R_j Rj is source pose
      • matrix subtraction is multiplying inverse
    • A j = D j T j = ( S j R j − 1 ) T j A_j = D_jT_j = (S_jR_j^{-1})T_j Aj=DjTj=(SjRj1)Tj
      • A j A_j Aj is new additive pose
      • T j T_j Tj is the target pose we want to add on
  • Diffrence clip can alse be temporal LERP
  • Additive blend percentage
    • for example, half-tired
    • LERP as usual
    • A j = L E R P ( T j , D j T j , β ) = ( 1 − β ) ( T j ) + β ( D j T j ) A_j = LERP(T_j, D_jT_j, \beta) = (1-\beta)(T_j) + \beta(D_jT_j) Aj=LERP(Tj,DjTj,β)=(1β)(Tj)+β(DjTj)
  • Additive v.s. Partial Blending
    • additive blending looks more natural
    • limitations of additive blending
      • over rotate of joint when applying multiple additive clips
      • carefully choose reference clip and target clip
        • keep hip rotations to a minimum in the reference clip
        • shoulder and elbow joints should be in neutral poses in the reference clip
        • new difference clip should be created for each core pose
  • Applications for additive blending
    • stance variation: difference clip is each stance
    • locomotion noise: add randomness to locomotion movements
    • Aim and Look-At: add partial difference to aim partially
    • overloading the time axis: use LERP to blend between difference clips
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值