Motion Blur like Doom4

I am getting identical result with those pixel shaders.

Also it turns out the path argument required to be enclosed in quotation marks to get all three folders across.

WithMask: Same as Final
WithoutMask: A screen filling flickering in tones of the room with the occasional contour of a window. The gun is rendered fine.
ViewportAlpha: Like Final, but with a pitch black gun.


void PS()
float weaponmask = texture2DProj(sDiffMap, vScreenPos).a;

//gl_FragColor = vec4(mask);

if (weaponmask == 0)
    gl_FragColor = texture2DProj(sDiffMap, vScreenPos).rgba;

float depth = ReconstructDepth(texture2DProj(sDepthBuffer, vScreenPos).r);

vec3 worldPos = vFarRay * depth / vScreenPos.w;
worldPos += cCameraPosPS;

vec4 oldClipPos = vec4(worldPos, 1.0) * cOldViewProj;
oldClipPos /= oldClipPos.w;

vec4 oldScreenPos = vec4(oldClipPos.x * vGBufferOffsets.z + vGBufferOffsets.x * oldClipPos.w,
                    oldClipPos.y * vGBufferOffsets.w + vGBufferOffsets.y * oldClipPos.w,
                    0.0, oldClipPos.w);

vec4 offset = (vScreenPos - oldScreenPos);
offset = offset / (cTimeStep * 20.0);

gl_FragColor = offset;


It should show different colors when you move a the mouse

Also try to remove all comments from shader. May be it not works with UTF8 comments

Also are you using the latest version of the engine?


Repo moved to

Is it possible to use the same technique for a depth of field effect?

I think there is nothing in common. Even pixel blurring algorithm is other. Easier write a DOF shader from scratch, than try to take something useful from this