Saturday, March 26, 2011

Thoughts on Muzzleflashes

Been thinking some about muzzle flashes on view models. If you know your history, you'll be aware that the combination of frame interpolation and muzzle flashes is evil, and can give visual glitches such as the flash moving back and forth between the two barrels on the Nailgun.

Up to now DirectQ has had a solution (of sorts) where it could selectively disable interpolation for parts of a model on a per-vertex level. However I've always been wary of this as it's based on a reasonably fuzzy heuristic which may not always be valid. The fact that it has been valid so far is neither here nor there: someday a model will appear that invalidates it.

I'm also doing some more optimization work on MDLs which breaks this solution (of sorts) so matters are coming to a head with regard to how to deal with it. I could of course undo that work, say "it's fast enough already", and put things back the way they were, but that wouldn't do anything about the risk of the solution (of sorts) becoming invalid in the future.

So I'm thinking that it's better to do something now rather than wait until it does break and then have to rush a fix. The options available seem to include these.

Just don't interpolate view models

This may yet be a viable approach, but in reality it's just exchanging one visual degradation in quality for another. If no other solution proves workable it is however what ID Quake did, so it's got a lot going for it.

Interpolate them anyway - it's a content bug!

DarkPlaces does this, and it's also viable from one perspective. However I don't see it as being an absolute content bug, as the setup of muzzle flashes was valid within the original parameters of ID Quake.

Copy what FitzQuake does and disable interpolation for two frames when the poses change

This fully resolves the muzzleflash problem in exchange for a small loss in smoothness. It seems a fair tradeoff, and has the advantage that it's an already accepted solution.

Do something sexy with the models that works with the new optimizations

I seriously thought about things like removing the muzzleflashes from the models and replacing them with a sprite, or drawing viewmodels twice - once without the flash vertexes and interpolated, once with only the flash vertexes and not interpolated. Both of these (especially the latter) seem attractive and interesting, but both of them also depend on that fuzzy heuristic to identify the flash vertexes which might break in the future.

So right now I'm leaning towards copying from Fitz as being the lesser of all evils, and it's probably sufficient as a shorter term solution. Longer term I am genuinely interested by the idea of drawing the models twice, and perhaps adding some user-configurability for the heuristic and for viewmodel interpolation in general.

0 comments: