   How to archive melee weapon motion blur ?
  I want to archive a special trail or motion blur effect for melee weapons only. Think of a fast moving sword in a FPS game, where the sword animationwill be only visible for a couple of frames. A good example is the katana or axe in Left for Dead 2. I have no idea how to archive such an effect. Is it possible to use a vertex shader to strech the model in movement direction ? Is a post-processing effect possible ? Should I render the model several times ?Any thought is welcome :)   
  Motion Blur for a single moving object can be achieved by rendering the object multiple times with increasing transparency for the older positions. But to make this look good you will also need some kind of filter on the resulting image to avoid hard edges. Best would be to render the moving object into seperate render targets (have n render targets for this). Then you can simple blend in those older frames of the sword position to the current one using your n render targets. The older a render target content is the less is its blending weight. If you are using DirectX then have a look at the DX samples, there is also a motion blur sample if I remember right.   ;  The way you accumulate motion blur depends on the kind of motion blur you want to have.Waterwalker's blur is how TFTs motion blur looks like, because of afterglow.For cameras:An object that moves with constant speed contributes at every moment of movement the same amount of information to the image. If you simulate that by rendering several frames or by sampling along motion vectors, you have to add the object with the same intensity, each by 1/sample_count .For games, motion blur is not the only way to show dynamic, you could also achive that by rendering a trail of transparent polygones, although completely unrealistic, this gives quite a nice visual effect.But if you really want to have motion blur for a sword, I'd draw it n-times if I were you.   ;Quote:Original post by Ashaman73Is it possible to use a vertex shader to strech the model in movement direction ?Such has been described in Shader X2. Online version of unknown (read as: questionable) legitimacy at Google.If you do deferred shading (or one if its variants), you can also render per pixel motion vectors into a G-buffer channel, that was described for example in Deferred rendering in Killzone 2".Or, you could be cheap and just add some half-transparent polygon trail. This could be part of the model/animation, or if you have a working physics engine, you could probably get a believeable effect if you attach a relatively stiff but weightless cloth to the weapon's edge.   ;  Check this out:http://http.developer.nvidia.com/GPUGems3/gpugems3_ch27.htmlThis article describes howto do motion blur as a post effect, without all kinds of expensive tricks (except blurring itself is relative heavy). Basically you- store previous camera modelview matrices- use previous matrix to recalculate the previous position of each pixel- measure distance between current and previous position. This vector is the motion vector, per pixel. The bigger it is, the more blur.Now this does not directly work for moving objects, only if the camera moves. But wait, it's not so hard to extend that. Like Samoth pointed out, it's easy to integrate in deferred rendering. But you can also do without. A single background pass that stores motion vectors is enough:- switch to a FBO / render target. Eventually a downscaled one to win some speed. You'll draw XY motion vectors to this buffer. - You can draw the static environment as described with the camera movement differences, if you like. Otherwise just give it a 0,0 motion vector.- Same thing for objects. However, if they move, add that vector as well. You'll need to convert a 3D movement vector (from it's animation or physics) to a 2D screen vector, and add it to the motion vector.- Finally render your scene as ussual, and apply the blur on top as described in the article.A tricky part may be defining your motion vector. With physics it's easy, just pass the movement direction/velocity to your shader. but swinging swords ussually comes from an (skeleton) animation. And while that swords moves quickly, the rest of the body may be pretty stationary. A single motion vector parameter for the entire object is not sufficient.What you could do is measure the distance and direction from a joint or vertex between 2 cycles. For example, sample the sword-tip (joint/vertex) at frame1, store its world position. Then when the next cycle comes, do it again. Then measure the difference between the two for a vector and distance. Use this as shader input. To prevent the entire body from getting blurred, render the body with a motion-amplifier texture. Black pixels = no motion, white pixels = maximum motion. Multiply these pixels with the motion vector. Or instead, calculate the motion for each joint and use multiple motion vectors as an input array, bound to the vertices. Or just seperate the sword object from the body...Good luck[Edited by - spek on April 8, 2010 4:29:29 PM];  Thanks for your input :-)It seems to be difficult :/ All methods which uses transparency are quite difficult to archive, because I use a deferred rendering engine. On the other hand using the motion vector approach in a deferred shader seems to work only on the object itself, which means, that there will be no trail, but only a blurred weapon.I think that a motionblur effect with trail would be best, cause when the frames drops to 15-20 fps you will only see the weapon animation for 3-5 frames. A trail would help to get a feeling of the animation.I will take a closer look at the given sources, maybe a combination of the given techniques will do.