53
Bones Skeletal Unity-2D How & When BY: MAHIR GULZAR (Computer Graphics Seminar)

Bones Skeletal Unity-2D How & When...Goals: • Good concept of skeletal animation pipeline • Basic knowledge to work with 2D sprites • A working package to get hands on experience

  • Upload
    others

  • View
    6

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Bones Skeletal Unity-2D How & When...Goals: • Good concept of skeletal animation pipeline • Basic knowledge to work with 2D sprites • A working package to get hands on experience

Bones Skeletal Unity-2D How & When

BY: MAHIR GULZAR

(Computer Graphics Seminar)

Page 2: Bones Skeletal Unity-2D How & When...Goals: • Good concept of skeletal animation pipeline • Basic knowledge to work with 2D sprites • A working package to get hands on experience

Agenda

• Introduction

• Core Terminologies (Descriptive)

• Spritesheet Animation

• Unity Anima-2D

• A Short Demonstration

• Summary

Page 3: Bones Skeletal Unity-2D How & When...Goals: • Good concept of skeletal animation pipeline • Basic knowledge to work with 2D sprites • A working package to get hands on experience

Goals:

• Good concept of skeletal animation pipeline

• Basic knowledge to work with 2D sprites

• A working package to get hands on experience

By the end of the presentation you would have:

Page 4: Bones Skeletal Unity-2D How & When...Goals: • Good concept of skeletal animation pipeline • Basic knowledge to work with 2D sprites • A working package to get hands on experience

Introduction

Have you ever wondered how a character walks, jumps,

run or do many more human like actions in games ?

• Yes they are animations

• How are they made?

Page 5: Bones Skeletal Unity-2D How & When...Goals: • Good concept of skeletal animation pipeline • Basic knowledge to work with 2D sprites • A working package to get hands on experience

Introduction

• Major 3D softwares like 3ds Max and Maya have built-in

functionality of Bone System.

• Models are rigged with boning and are exported as complete

package.

Page 6: Bones Skeletal Unity-2D How & When...Goals: • Good concept of skeletal animation pipeline • Basic knowledge to work with 2D sprites • A working package to get hands on experience

Introduction

• 3D games today use these pre-rendered animations which are

exported with the 3D model.

• You import the model as well as the animations which are

provided with it.

• Not just Humanoid but other Generic animations as well.

Page 7: Bones Skeletal Unity-2D How & When...Goals: • Good concept of skeletal animation pipeline • Basic knowledge to work with 2D sprites • A working package to get hands on experience

Confused?

Page 8: Bones Skeletal Unity-2D How & When...Goals: • Good concept of skeletal animation pipeline • Basic knowledge to work with 2D sprites • A working package to get hands on experience

Lets Talk about Core Terminologies

• Bones

• Joints

• Inverse Kinematics (IK)

• Mesh Deformation (Skinning)

• Rig (Rigging)

Page 9: Bones Skeletal Unity-2D How & When...Goals: • Good concept of skeletal animation pipeline • Basic knowledge to work with 2D sprites • A working package to get hands on experience

How many bones should be here..

Page 10: Bones Skeletal Unity-2D How & When...Goals: • Good concept of skeletal animation pipeline • Basic knowledge to work with 2D sprites • A working package to get hands on experience

How many bones should be here..

• 2 Right?

Source: http://apprize.info/programming/direct3d/5.html

Page 11: Bones Skeletal Unity-2D How & When...Goals: • Good concept of skeletal animation pipeline • Basic knowledge to work with 2D sprites • A working package to get hands on experience

Bones

• A gameObject (type of object) in 3d/2d world space

• Represents set of vertices.

• Independently movable.

• Can have parent child relationship in hierarchy.

• In-fact no physical and calculable presence in a scene.

Page 12: Bones Skeletal Unity-2D How & When...Goals: • Good concept of skeletal animation pipeline • Basic knowledge to work with 2D sprites • A working package to get hands on experience

Two Gameobjects

Source: http://apprize.info/programming/direct3d/5.html

Page 13: Bones Skeletal Unity-2D How & When...Goals: • Good concept of skeletal animation pipeline • Basic knowledge to work with 2D sprites • A working package to get hands on experience

Joints

• Building block of skeletons

• Point of articulation (contact between bones)

• No Shape

• Bones attached with each other through joint.

Page 14: Bones Skeletal Unity-2D How & When...Goals: • Good concept of skeletal animation pipeline • Basic knowledge to work with 2D sprites • A working package to get hands on experience

Joints

• Consider them as hooks on both sides of a

stick..

Page 15: Bones Skeletal Unity-2D How & When...Goals: • Good concept of skeletal animation pipeline • Basic knowledge to work with 2D sprites • A working package to get hands on experience

Joints Types

• Ball Joint

• Universal Joint

• Hinge Joint

Page 16: Bones Skeletal Unity-2D How & When...Goals: • Good concept of skeletal animation pipeline • Basic knowledge to work with 2D sprites • A working package to get hands on experience

Joints Types

• Ball Joint

A ball joint is a joint that can rotate

about all three of its local axes. For

example, the human shoulder is a ball joint.

Page 17: Bones Skeletal Unity-2D How & When...Goals: • Good concept of skeletal animation pipeline • Basic knowledge to work with 2D sprites • A working package to get hands on experience

Joints Types

• Universal Joint

A universal joint is a joint that can rotate

about only two of its local axes. The human

wrist is a good example of a universal joint,

though the wrist has limitations on the

extent it can rotate.

Page 18: Bones Skeletal Unity-2D How & When...Goals: • Good concept of skeletal animation pipeline • Basic knowledge to work with 2D sprites • A working package to get hands on experience

Joints Types

• Hinge Joint

A hinge joint is a joint that can rotate

about only one of its local axes. For

example, the human knee is a hinge joint.

Page 19: Bones Skeletal Unity-2D How & When...Goals: • Good concept of skeletal animation pipeline • Basic knowledge to work with 2D sprites • A working package to get hands on experience

Joint Attributes

• Limits

• Degree of freedom

• Damping

• Stiffness

Page 20: Bones Skeletal Unity-2D How & When...Goals: • Good concept of skeletal animation pipeline • Basic knowledge to work with 2D sprites • A working package to get hands on experience

Joint Attributes

• Limits

Joint Limit Information attributes specify the minimum and maximum translation, rotation, and scaling values for a joint. For example elbow rotation.

• Degree of Freedom

The Degrees of freedom determines which local axes the joints

can rotate.

Page 21: Bones Skeletal Unity-2D How & When...Goals: • Good concept of skeletal animation pipeline • Basic knowledge to work with 2D sprites • A working package to get hands on experience

Joint Attributes

• Damping

Joint damping applies resistance to a joint as it approaches its joint limits. Instead of the joint abruptly stopping when it reaches its limits, you can smooth it with damping.

• Stiffness

Joint stiffness specifies a joint’s resistance to rotation during

inverse kinematics animations.

Page 22: Bones Skeletal Unity-2D How & When...Goals: • Good concept of skeletal animation pipeline • Basic knowledge to work with 2D sprites • A working package to get hands on experience

Inverse Kinematics (IK)

Page 23: Bones Skeletal Unity-2D How & When...Goals: • Good concept of skeletal animation pipeline • Basic knowledge to work with 2D sprites • A working package to get hands on experience

Inverse Kinematics (IK)

• A very powerful tool in game development.

• Originated from Robotics

• Purpose is to calculate positions for a joint system so that it

will reach a certain end goal.

Page 24: Bones Skeletal Unity-2D How & When...Goals: • Good concept of skeletal animation pipeline • Basic knowledge to work with 2D sprites • A working package to get hands on experience

Inverse Kinematics (IK)

For the idea lets just define forward kinematics first.

• I have a starting point (for example, the equivalent of

your shoulder on your arm),

I should be able to calculate the end position with some

mathematical function right ?

• The length of all the parts,

• The angles between those parts,

Page 25: Bones Skeletal Unity-2D How & When...Goals: • Good concept of skeletal animation pipeline • Basic knowledge to work with 2D sprites • A working package to get hands on experience

Inverse Kinematics (IK)

• Forward Kinematics: Example

Page 26: Bones Skeletal Unity-2D How & When...Goals: • Good concept of skeletal animation pipeline • Basic knowledge to work with 2D sprites • A working package to get hands on experience

Inverse Kinematics (IK)

Inverse Kinematics isn’t about getting the end effector.

• I have the endpoint or the goal.

In other words the angles on each joint must be calculated

• I want to find a configuration of joint system.

• So that it will reach the goal.

Page 27: Bones Skeletal Unity-2D How & When...Goals: • Good concept of skeletal animation pipeline • Basic knowledge to work with 2D sprites • A working package to get hands on experience

Inverse Kinematics (IK)

• Inverse Kinematics: Example

Page 28: Bones Skeletal Unity-2D How & When...Goals: • Good concept of skeletal animation pipeline • Basic knowledge to work with 2D sprites • A working package to get hands on experience

• A Better Demonstration

Page 29: Bones Skeletal Unity-2D How & When...Goals: • Good concept of skeletal animation pipeline • Basic knowledge to work with 2D sprites • A working package to get hands on experience

FABRIK Algorithm: Forward and Backward Reaching IK

• Sets the end position at the target.

• Work backward and forward by finding the line

between the most recently updated point and next

point in chain.

Two Stages:

Page 30: Bones Skeletal Unity-2D How & When...Goals: • Good concept of skeletal animation pipeline • Basic knowledge to work with 2D sprites • A working package to get hands on experience

FABRIK Algorithm: Forward and Backward Reaching IK

Page 31: Bones Skeletal Unity-2D How & When...Goals: • Good concept of skeletal animation pipeline • Basic knowledge to work with 2D sprites • A working package to get hands on experience

FABRIK Algorithm: Forward and Backward Reaching IK

Page 32: Bones Skeletal Unity-2D How & When...Goals: • Good concept of skeletal animation pipeline • Basic knowledge to work with 2D sprites • A working package to get hands on experience

FABRIK Algorithm: Forward and Backward Reaching IK

Page 33: Bones Skeletal Unity-2D How & When...Goals: • Good concept of skeletal animation pipeline • Basic knowledge to work with 2D sprites • A working package to get hands on experience

Inverse Kinematics

http://www.academia.edu/9165835/FABRIK_A_fast_iterative_solver_for_the_Inv

erse_Kinematics_problem

• There are many other robust algorithms other than

fabric but I’ll stop here because we understood the

basic idea behind computation of Inverse Kinematics.

Page 34: Bones Skeletal Unity-2D How & When...Goals: • Good concept of skeletal animation pipeline • Basic knowledge to work with 2D sprites • A working package to get hands on experience

NOT SO FAST..!!!

Why do we really need Inverse Kinematics ?

Page 35: Bones Skeletal Unity-2D How & When...Goals: • Good concept of skeletal animation pipeline • Basic knowledge to work with 2D sprites • A working package to get hands on experience

Mesh Deformation (Skinning)

• A 3D model is built on mesh of polygons.

• Polygons have vertices.

• The goal of mesh deformation is to move vertices.

Source:

http://help.shade3d.jp/en/support/ShadeHelp/latest/Manual/Reference/200_Animation_Rel

ated/WeightPainting/02_WeightPainting.html

• http://www.alecjacobson.com/weblog

/media/skinning-demo.gif

• http://catlikecoding.com/unity/tutorials/mesh-

deformation/

Cool Demos:

Page 36: Bones Skeletal Unity-2D How & When...Goals: • Good concept of skeletal animation pipeline • Basic knowledge to work with 2D sprites • A working package to get hands on experience

Mesh Deformation (Skinning)

• Envelopes

Source: http://www.peachpit.com/articles/article.aspx?p=483773&seqNum=3

Book: Digital Character Animation-3

• Painted Weight

• Numerical Assignment (Advanced)

Page 37: Bones Skeletal Unity-2D How & When...Goals: • Good concept of skeletal animation pipeline • Basic knowledge to work with 2D sprites • A working package to get hands on experience

Rigging (The Whole Process)

• Well everything we understood previously is called

rigging.

• To make it simple it’s a process of creating skeleton

so that the model or character can move.

• A very technical and overwhelming process.

Page 38: Bones Skeletal Unity-2D How & When...Goals: • Good concept of skeletal animation pipeline • Basic knowledge to work with 2D sprites • A working package to get hands on experience

Material: Advanced Methods in

Computer Graphics

Page 39: Bones Skeletal Unity-2D How & When...Goals: • Good concept of skeletal animation pipeline • Basic knowledge to work with 2D sprites • A working package to get hands on experience

So Far So Good….

• We understood how bone skeleton works in general.

• The idea behind this whole discussion was to introduce

2D Bone Skeletal in Unity Engine.

• You know the basics this will be easy now…

Page 40: Bones Skeletal Unity-2D How & When...Goals: • Good concept of skeletal animation pipeline • Basic knowledge to work with 2D sprites • A working package to get hands on experience

Spritesheet Animation (Naive Method)

• Multiple sprites on single sheet (Better optimization)

• Swap images rapidly to see the animation.

Page 41: Bones Skeletal Unity-2D How & When...Goals: • Good concept of skeletal animation pipeline • Basic knowledge to work with 2D sprites • A working package to get hands on experience

Spritesheet Animation (Naive Method)

• Large Storage

• Inflexible

• Not Smooth

• Great Performance

Page 42: Bones Skeletal Unity-2D How & When...Goals: • Good concept of skeletal animation pipeline • Basic knowledge to work with 2D sprites • A working package to get hands on experience

Unity Anima-2D (Skeletal Animation)

• Small Textures

• Flexible

• Smooth

• Enabling Skinning

• Enable Procedural Animations

• CPU/GPU Intensive

Page 43: Bones Skeletal Unity-2D How & When...Goals: • Good concept of skeletal animation pipeline • Basic knowledge to work with 2D sprites • A working package to get hands on experience

Unity Anima-2D (Skeletal Animation)

• We need

• Just Sprites nothing else

• Wait… What about Skinning?

• Precise Geometry

• Bones, joints, Inverse kinematics

• High quality weights

Page 44: Bones Skeletal Unity-2D How & When...Goals: • Good concept of skeletal animation pipeline • Basic knowledge to work with 2D sprites • A working package to get hands on experience

Unity Anima-2D Components

• Bone2D

• Sprite Mesh Instance

• IK Limb 2D

• IK CCD2D

• Pose Manager

Page 45: Bones Skeletal Unity-2D How & When...Goals: • Good concept of skeletal animation pipeline • Basic knowledge to work with 2D sprites • A working package to get hands on experience

Unity Anima-2D Components

• Bone2D

Page 46: Bones Skeletal Unity-2D How & When...Goals: • Good concept of skeletal animation pipeline • Basic knowledge to work with 2D sprites • A working package to get hands on experience

Unity Anima-2D Components

• Sprite Mesh Instance

Page 47: Bones Skeletal Unity-2D How & When...Goals: • Good concept of skeletal animation pipeline • Basic knowledge to work with 2D sprites • A working package to get hands on experience

Unity Anima-2D Components

• Ik Limb 2D

Page 48: Bones Skeletal Unity-2D How & When...Goals: • Good concept of skeletal animation pipeline • Basic knowledge to work with 2D sprites • A working package to get hands on experience

Unity Anima-2D Components

• Ik CCD2D

Page 49: Bones Skeletal Unity-2D How & When...Goals: • Good concept of skeletal animation pipeline • Basic knowledge to work with 2D sprites • A working package to get hands on experience

Unity Anima-2D Components

• Pose Manager

Page 50: Bones Skeletal Unity-2D How & When...Goals: • Good concept of skeletal animation pipeline • Basic knowledge to work with 2D sprites • A working package to get hands on experience

Demo Time ;)

Page 51: Bones Skeletal Unity-2D How & When...Goals: • Good concept of skeletal animation pipeline • Basic knowledge to work with 2D sprites • A working package to get hands on experience

References and Links

1. Bones and Vertices: http://apprize.info/programming/direct3d/5.html

2. Vertices:

• https://en.wikibooks.org/wiki/Blender_3D:_Noob_to_Pro/Advanced_Tutorials/Advan

ced_Animation/Guided_tour/Mesh/vg

• http://help.shade3d.jp/en/support/ShadeHelp/latest/Manual/Reference/200_Anim

ation_Related/WeightPainting/02_WeightPainting.html

3. Joints:

• https://knowledge.autodesk.com/support/maya/learn-

explore/caas/CloudHelp/cloudhelp/2016/ENU/Maya/files/GUID-1B59334F-2605-

44C3-B584-A55B239A2CBE-htm.html

• https://se.mathworks.com/help/physmod/sm/mech/ref/universal.html

4. Inverse Kinematics:

• http://wiki.roblox.com/index.php?title=Inverse_kinematics

Page 52: Bones Skeletal Unity-2D How & When...Goals: • Good concept of skeletal animation pipeline • Basic knowledge to work with 2D sprites • A working package to get hands on experience

References and Links

5. Anima-2D:

• https://anima2d.com/documentation

• https://www.assetstore.unity3d.com/en/#!/content/45879

Page 53: Bones Skeletal Unity-2D How & When...Goals: • Good concept of skeletal animation pipeline • Basic knowledge to work with 2D sprites • A working package to get hands on experience

Thank You