Previously DirectQ has used something of a hack for interpolation; this was needed to fix the muzzleflash animations on weapon models and worked by disabling interpolation for certain vertexes if they had moved beyond a certain amount between the first two frames in the model.
While it works perfectly fine for all viewmodels in all mods I've tested, there remains a possibility that at some point in time it's going to break.
Recently I've been experimenting with a weighted blend run on the GPU in a vertex shader. Once again, it calculates the difference between two positions, but rather than being a binary on/off result it rescales the blend factor so that larger differences blend less.
Aside from working correctly with standard viewmodels, this has a number of other consequences.
It will work correctly with any pair of frames. If a viewmodel doesn't show it's muzzleflash animation until the third or fourth frame, it will work.
It works with other models that have muzzleflash animations, such as the Grunt.
It scales smoothly so that if the vertexes don't move beyond the old cutoff point it can still give you something that's better than nothing.
It evaluates a correct 3 dimensional distance, rather than the old one-dimensional distance that the old method used.
Sudden movements over larger distances will not interpolate as smoothly. I'm in two minds about this one; on the one hand I don't think they should (and some models don't look that great if they're caught between two such frames), but on the other hand some smoothness is lost in dying animations.
It's fast.
It can be made user-configurable.
I'm not committed to switching over to this system in any live codebase just yet, but I'm inclining towards thinking that it does represent a good way forward with general handling of interpolation. Anyone have any opinions?
Tuesday, January 3, 2012
A Consideration Regarding Interpolation
Posted by
mhquake
at
11:06 PM
Subscribe to:
Post Comments (Atom)
1 comment:
Besides using replacement models made with interpolation in mind, this seems to be the best solution I've heard of so far.
What's nice about it is that it isn't a hack, and therefore should make the code easier to maintain.
Post a Comment