DOC PREVIEW
GT ECE 4893 - Animation

This preview shows page 1-2-3 out of 9 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

AnimationProf. Aaron LantermanSchool of Electrical and Computer EngineeringGeorgia Institute of Technology2Typical keyframed animations• Standing• Running• Kneeling• Ducking• Attacking• Passing on, ceasing to be, expiring and going tomeet maker, pushing up the daisies, kicking thebucket, shuffling off mortal coil, running down thecurtain, joining the invisible choir, becoming anex-parrotFrom Fernando & Kilgard, “The Cg Tutorial,” 2003, p. 1553Basic keyframing (fragment shader)void C6E3v_keyFrame(float3 positionA : POSITION, float3 positionB : TEXCOORD1, float4 color : COLOR, float2 texCoord : TEXCOORD0, out float4 oPosition : POSITION, out float2 oTexCoord : TEXCOORD0, out float4 oColor : COLOR, uniform float keyFrameBlend, uniform float4x4 modelViewProj){ float3 position = lerp(positionA, positionB, keyFrameBlend); oPosition = mul(modelViewProj, float4(position, 1)); oTexCoord = texCoord; oColor = color;}From Fernando & Kilgard, “The Cg Tutorial,” 2003, p. 1594A Light structurestruct Light { float3 eyePosition; // In object space float3 lightPosition; // In object space float4 lightColor; float specularExponent; float ambient;};From Fernando & Kilgard, “The Cg Tutorial,” 2003, p. 1615Keyframing with lighting (vertex shader)void C6E4v_litKeyFrame(float3 positionA : POSITION, float3 normalA : NORMAL, float3 positionB : TEXCOORD1, float3 normalB : TEXCOORD2, float2 texCoord : TEXCOORD0, out float4 oPosition : POSITION, out float2 oTexCoord : TEXCOORD0, out float4 color : COLOR, uniform float keyFrameBlend, uniform Light light, uniform float4x4 modelViewProj){ float3 position = lerp(positionA, poitionB, keyFrameBlend); float3 blendNormal = lerp(normalA, normalB, keyFrameBlend); float3 normal = normalize(blendNormal); oPosition = mul(modelViewProj, float4(position, 1)); oTexCoord = texCoord; color = computeLighting(light, position, normal);}From Fernando & Kilgard, “The Cg Tutorial,” 2003, p. 1626Compute lightingfloat4 computeLighting(Light light, float3 position, // In object space float3 normal) // In object space{ float3 lightDirection = light.lightPosition - position; float3 lightDirNorm = normalize(lightDirection); float3 eyeDirection = light.eyePosition - position; float3 eyeDirNorm = normalize(eyeDirection); float3 halfAngle = normalize(lightDirNorm + eyeDirNorm); float diffuse = max(0,dot(lightDirNorm, normal)); float specular = pow(max(0,dot(halfAngle, normal)), light.specularExponent); return light.lightColor * (light.ambient + diffuse + specular);}From Fernando & Kilgard, “The Cg Tutorial,” 2003, p. 1617Skinning, part 1 (vertex shader)void C6E5v_skin4m(float3 position : POSITION, float3 normal : NORMAL, float2 texCoord : TEXCOORD0, float4 weight : TEXCOORD1, float4 matrixIndex : TEXCOORD2, out float4 oPosition : POSITION, out float2 oTexCoord : TEXCOORD0, out float4 color : COLOR, uniform Light light, uniform float4 boneMatrix[72], // 24 matrices uniform float4x4 modelViewProj){ …From Fernando & Kilgard, “The Cg Tutorial,” 2003, p. 1668Skinning, part 2 (vertex shader) … float3 netPosition = 0, netNormal = 0; for (int i=0; i<4; i++) { float index = matrixIndex[i]; float3x4 model = float3x4(boneMatrix[index+0], boneMatrix[index+1], boneMatrix[index+2]); float3 bonePosition = mul(model, float4(position, 1)); // Assume no scaling in matrix, just rotate & translate float3x3 rotate = float3x3(model[0].xyz, model[1].xyz, model[2].xyz); float3 boneNormal = mul(rotate, normal); netPosition += weight[i] * bonePosition; netNormal += weight[i] * boneNormal; } …From Fernando & Kilgard, “The Cg Tutorial,” 2003, p. 1669Skinning, part 3 (vertex shader) … netNormal = normalize(netNormal); oPosition = mul(modelViewProj, float4(netPosition, 1)); oTexCoord = texCoord; color = computeLighting(light, netPosition, netNormal);}From Fernando & Kilgard, “The Cg Tutorial,” 2003, p.


View Full Document

GT ECE 4893 - Animation

Documents in this Course
Load more
Download Animation
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Animation and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Animation 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?