Jump to content
  • Advertisement
Sign in to follow this  
spek

bumpmapping on animated models

This topic is 4352 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I want to do bumpmapping on an animated model, a smd(halflife1) skeletal animated model. I'm using tangents/biTangents/normals, but of course, they are not correct anymore once the model starts changing. I think I need "vertex skinning" to solve this, but I'm not sure though... So, what technique to use? And, are there any nice demo's of it somewhere? Greetings, Rick

Share this post


Link to post
Share on other sites
Advertisement
well if you only pass the normal you can recalculate the tangent/bi in a vertex shader.
check this out.
Clicky

hope it was what you where after.

Share this post


Link to post
Share on other sites
So I don't have to pre-calculate the tangents/biTangents at all? I always thought the calculation of tangents was depending on more than just 1 normal.

Anyway, thanks for the tip! But it brings to me to another problem. It has nothing to do with tangents, but it must work before I can do proper bumpMapping. The lighting is wrong. For now I'm just using simple lighting ( dot(L,N) ). But the model can rotate itself, so I have to convert the lightPosition (and camera) first to object-space in the vertex shader. Otherwise the comparison between the normal and the lightVector will be incorrect. However, I'm doing something wrong.


/*** VERTEX SHADER ***/
// Bring the vertex to world-space
float3 ow = mul( modelView, in.pos.xyzw ).xyz;

// Calculate lightVector
// Light pos is an absolute coordinate, world-space
out.lightV = normalize( lightPos.xyz - ow );

// Bring the lightVector to object-space
// modelView is a 3x3 matrix, don't know if that gives
// problems... lightV is a float3
out.lightV = mul( modelViewInverse, out.lightV );

// The normal is already in object-space, just pass it
out.normal = in.normal;

/*** PIXEL SHADER ***/
// The result color
out.color = dot( in.normal, normalize( in.lightV ) );


In the first case the lighting seems to be right, but when starting to rotate around the object, it's not correct. The lighting seems to be dependant on the camera angle(and how much you zoomed into it), but it shouldn't be.

I'm not good with matrices, so I guess I'm converting in the wrong order or the wrong things. For example, I have my doubts with "bring vertex to world-space". The model has not been animated/rotated/scaled or transformed yet, so the in.pos is already world-space. When multuplying it with the modelView matrix I get different results though.

So, how to bring the lightPosition(and camera) into object-space so that I can make a good comparison with the normal (and later bring it to tangent-space)?

Greetings,
Rick

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!