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

Interpolating between normals?

Started by My_Mind_Is_Going Jun 29, 2007 at 1:15 PM 2 replies 900+ views
Original Post
My_Mind_Is_Going
My_Mind_Is_Going
I'm in the process of writing my awesome MD2 key-frame animation class. For rending the actual frames contained in the model itself I've been using id's table of precomputed normals which has been working nicely. Now that I'm working on tweening between keyframes however I have the problem that most of the things I'm rendering are interpolations between one frame and another so the precomputed normals don't work anymore because I'm not using the vertices from either frame but some linear combination of them. Because I do know the normals for the first frame and the one I'm going to I thought maybe I can interpolate between the two normals just like I've been doing for the vertices but it is giving very sketchy results... has anyone ever heard of doing something like this? Should I be trying to find a better method for calculating the interpolated normal besides just nx_current = nx_start + interpolation_percent * (nx_end - nx_start), etc? Or should I just break down and compute all the correct normals myself from the actual vertices I'm using?
OrangyTang
OrangyTang
Just doing a regular linear interpolation of the keyframe normals and then normalising the result is the typical way IIRC. As long as your start and end normals are reasonably similar (which for animation keyframes they probably are) then this should give good results.

If you need something better then perhaps convert them both into quaternions, interpolate between these and then convert back into a normal vector. Thats likely to be somewhat slower but more accurate.
EternalNewbie
EternalNewbie
The accurate way of calculating the normal is being SLERP'ing (using Spherical interpolation) But the calculation is expensive which is why you'll almost always see it done as a linear interpolation, which is then renormalised.

The formula for SLERP is:-

N(t) = N0(sin(1-t)θ/sinθ) + N1(Sin(tθ)/sinθ)

You can look it up on wikipedia or google if you need more detail.
My_Mind_Is_Going
My_Mind_Is_Going
Hmmm, well thanks for the info. The linear interpolation is giving me weird flickering triangles, but I suppose it's possible there's just an error somewhere.

Topic Locked

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

Sign in to reply to this topic.