   shading on animated models!
  Hi!A 3d model stores the vertex normals in object space. The engine caluclates the shading from this normals. If the model is rotated, then this rotation gets added to the normals so that they are still right in worldspace.But what about animated models? For example a human who swings his arm. the object normals are still stored in the vertices - but the bounding box (the local objectcoordinates respectivels) doesn't rotate or something like that - so the stored normal values are right in world space only if the arm is in startposition...So - can someone explain me how lighting (or other effects which are depend from meshnormals... like reflectionmapping and so on...) works on animated models??Thx!   
  What you do is compute your lighting in model space.  Taking your example of a moving arm, that arm has a transformation matrix that is applied to it so that is rendered at the right location.What you do is you take the inverse of that matrix and use it to transform your lighting parameters into the local space of that object.  This can all be done within your vertex shader.  Once your lighting parameters (in most cases just the position or direction of the light source) are in the same space as the vertices of your model, the pixel shader can perform its lighting calculations without even caring which space the data is in.Hope that makes sense.  If it doesn't, ask and I can try to explain it in more detail.neneboricua   ;  yes that's clear... if the arm is a single object it's no problem anyway...But an arm in general isn't an own object but just a bunch of vertices which are animated by envelopes constrained to a bone... so - if the arm moves, the local space of the object stays the same!   ;  If you are talking about the shading of skinned models -- it's simple.  All vertices (and therefore normals) in the skin are in the same coordinate system.  All you need is to calculate all bone matrices and calculate weighted sum of normal x matrix.Of course, it doesn't work correctly but this is the best you can do without going deep to the skin postprocess.   ;Quote:Original post by genesysBut an arm in general isn't an own object but just a bunch of vertices which are animated by envelopes constrained to a bone... so - if the arm moves, the local space of the object stays the same!What you do is you choose the space in which you are lighting your models.  Since you now mentioned you're using skinning to do your animation I can get a little more specific.To "skin" a vertex, you transform that vertex by the matrices representing the "bones" attached to it.  You then do the same thing to the normal of that vertex because the normal vectors must be skinned as well so that they're in the right space.  Or, more efficiently, you concatenate the appropriate bone matrices together first and then transform the position and normal vectors by this concatenated matrix, along with the associated weights.At this point, the vertex position and normal have been "skinned" and are now in model space.  This is where you perform your lighting computations.  Your application transforms all of your lighting parameters into model space like I mentioned previously.neneboricua   ;  ok thank you - now that's clear!But unfortunately i can't solve my problem that way :(The engine I use (irrlicht) doesn't seam to allow skinned models in realtime... It's working only when i plot the vertexposition for all the frames of the animation into my .X file so - i don't have any transformation matrizes :/   ;Quote:Original post by genesysThe engine I use (irrlicht) doesn't seam to allow skinned models in realtime... It's working only when i plot the vertexposition for all the frames of the animation into my .X file so - i don't have any transformation matrizes :/So the engine performs all skinning in software?  Well, if that's the case, then the engine should be skinning the normal vector right along with the original position.  So your shaders wouldn't need to transform the original position or normal vector at all because they would already been in model space because the engine performed the skinning manually.neneboricua   ;  no - it doesn't perform the skinning...i must plot my skinned model when i export it from my 3d program - means that for a 50frames animation the vertex position gets stored for every frame.   ;Quote:Original post by genesysno - it doesn't perform the skinning...i must plot my skinned model when i export it from my 3d program - means that for a 50frames animation the vertex position gets stored for every frame.Ok, then you've gotten a bit of terminology mixed up.  "Skinning" is the term used when refering to the transformation of vertices in a mesh due to a number of matrices and corresponding weights.  Skinning is one technique used in 3D mesh animation.  There are other techniques as well.  The one it seems your engine is using is called keyframe animation.The same idea I mentioned earlier still holds; if the engine is handling the animation in software, it will do so for the mesh vertices as well as the normals.  In the case of keyframe animation, these values are linearly interpolated between the frames of the mesh that are stored.  So when the mesh is rendered, the position and normal have been interpolated and are in model space.  So you only have to transform your lighting parameters to model space and you can operate on the vertex and normal vectors that get fed into the vertex shader without modifying them at all.neneboricua   