Skip to main content
GameDev.net gamedev.net
🔒 Locked 🎮 Unity

Skinning Problem

Started by princezahee Jan 15, 2013 at 6:46 PM 2 replies 1.5k views
Original Post
princezahee
princezahee

I have some problems with skinning. So, here are the steps i have done to perform skinning.

Export:
- When exported, all vertices are already in the reference pose.
- All bone transformations are absolute transformation. (Not relative to parent)
- bone offset matrix = inverse (bone transform matrix)
- bone matrix = bone matrix * inverse (parent bone matrix)

CPU:
- bone.transformMatrix = bone matrix (as exported)
- Loop through each bone
bone.absoluteMatrix = bone.transformMatrix * parentBone.absoluteMatrix

- Send bone.absoluteMatrix as the bone matrix to the GPU
- Send bone.offsetMatrix (as exported) as the bone offset matrix to the GPU

GPU:
for each vertex
vec4 tempVertex = [0, 0, 0, 0]

for each bone influencing this vertex
boneMatrix = boneMatrix[this bone] * boneOffsetMatrix[this bone]
tempVertex += (vertex * boneMatrix) * weight[this bone on this vertex]

tempVertex /= total weight

final vertex position = projection Matrix * view matrix * world matrix * tempVertex

So, the skinned mesh is not being rendered correctly and i am not being able to spot the problem but i know the problem comes from the matrices. The weights and bone influences are all right. Any1 can help please?

mrjones
mrjones

I might be completely off, but these are things that seem dubious to me:

1. Is it necessary to multiply bone matrix with bone offset matrix? I would probably simply multiply with offset matrix assuming that before passing to glsl it is already multiplied with parent offset matrix (that is in turn multiplied with its parent offset matrix and so on).

2. Is that the sum of aVertexWeights 0 to 1 guaranteed to be 1.0? If not, maybe divide finalVertex with sum of aVertexWeights.

L. Spiro
L. Spiro

Perhaps if you posted a picture of the broken model…

You would also be doing yourself a favor by posting in the appropriate section. More people familiar with OpenGL will see your topic and be able to help.

L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid
princezahee
princezahee

***I have updated the thread***

Please view the thread and help me.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.