Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411275 Posts in 69323 Topics- by 58380 Members - Latest Member: bob1029

March 28, 2024, 08:45:28 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsCommunityTownhallForum IssuesArchived subforums (read only)TutorialsSkinned Skeletal Animation Tutorial + Source Code
Pages: [1]
Print
Author Topic: Skinned Skeletal Animation Tutorial + Source Code  (Read 5265 times)
sp4cerat
Level 0
*



View Profile WWW
« on: March 04, 2014, 07:42:40 PM »

Today I completed a skinned skeletal animation tutorial, which is very helpful if you are just about to start with game development.

Different from the other tutorials I found in the web, this one is very light weight ( < 800 lines for the main mesh & animation code ) and works well with most modeling environments.

Summary

It has the following properties / features:
  • GPU Skinning / Matrix Palette Skinning
  • Bump Mapping (automatic normal map generation)
  • Spheric environment mapping
  • Ogre XML Based
  • Shaders in GLSL
  • Visual Studio 2010
  • Select LOD level with F1..F5

The workflow is as follows:
  • Design the Model in Maya/MAX/Blender/etc.
  • Export the model using the OgreExporter
  • Convert the model from Ogre binary to Ogre XML (batch file is included)
  • Load the model in the tutorial code


Main Skinning in GLSL:
 
The main skinning is done in the vertex shader and only requires a few lines.
For the shader, the skinning weights are stored in the color information as 3 floats.
The bone IDs are unpacked from the w coordinate of the position information.
The bone matrixes are stored as simple matrix array.
 
Code:
uniform mat4 bones[100];
uniform int  use_skinning;
 
void main(void)
{
    mat4 mfinal = gl_ModelViewMatrix ;

    if(use_skinning==1)  
    {
     vec3 weights= gl_Color.xyz;
     vec3 boneid = gl_Vertex.w * vec3( 1.0/128.0 , 1.0 , 128.0 );
     boneid = (boneid - floor(boneid))*128.0;
 
     mat4 mskin  = bones[int(boneid.x)]*weights.x+
    bones[int(boneid.y)]*weights.y+
bones[int(boneid.z)]*weights.z;
     mfinal = mfinal * mskin;
    }
    gl_Position = gl_ProjectionMatrix * mfinal * vec4(gl_Vertex.xyz,1.0);
}

Note:

Animating Notes for Maya
For Maya, put all animations in one time-line and export them as separate animations.

Ogre Export
Tangents need to be exported as 4D, to include the handedness. The tutorial version does not generate the tangents in the shader as it is faster to read them from the memory.

Bump Mapping
For the Ogre Material file, the bump map needs to be added manually by hand using the texture_bump parameter as follows:

texture Texture\masterchief_base.tif
texture_bump Texture\masterchief_bump_DISPLACEMENT.bmp

Environment Mapping
Environment mapping can be switched on in the material file using the following parameter:
env_map spherical
 
Source & Binaries
http://voxels.blogspot.com/2014/03/skinned-skeletal-animation-tutorial.html


Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic