OpenGL screen space motion blur

I am implementing motion blur based on the approach outlined in "Stupid OpenGL tricks".I also got the demo from NVidia OpenGL SDK.It is implemented using Cg while I am using GLSL.Needless to say it doesn't work for me after conversion,otherwise I wouldn't ask here for help.Also I am not sure I completely understand the logic of their implementation.

1) In the source code of the original example both modelView matrix and modelViewProjection matrix uniforms are identity matrices.I don't get it why? To me it seem that in such a case,because the matrices of the
previous frame are no identity,the velocity vector build would be wrong...
2) In CG vertex shader they fill varying "Out.hpos" with Pstretch which is used again after several lines to get transformed into 3D space...Why?

But texRECT uses al 4 components of wpos while GLSL texture() has no such an option.

So how do I go about it?

Currently this motion blur technique is the only one which is relatively clear to me and which operates both on camera and objects but I will also be happy to get reference to other (may be better) approaches.

1) You are setting gl_Position = position in your vertex shader, which means you aren't applying modelView/modelViewProjection to the vertices + whatever you set them to will have no effect. As far as I can tell, you should be setting gl_Position = PStretch and outCol = 0.5 + (dP.xy * 0.005).
2) The result of the calculation Pstretch.xyz = Pstretch.xyz / Pstretch.w isn't used, so can be safely commented out.

A more exact port of the original code would be to use samplerRect (texcoords from 0..width, 0..height) instead of sampler2D (texcoords from 0..1, 0..1), but as long as you've adjusted for this correctly it should be okay.

Looking at the code closer, velocity is a vec2 already so the vec2() cast wouldn't be needed.

In which way doesn't the line work, have you include a #version 330 directive (or alternative version) to target the correct GLSL version, otherwise you will need to use texture2D() instead of texture().