Motion Blur Tutorial for the Quake engine:

Here's a tutorial to add motion blur to your own version of the Quake engine.  I tested this out on the fresh source code from id software and also with some code that had several modifications (dynamic lights, model interpolation, etc) and it worked fine for both of them.  I've only tested this out with my GeForce2, but it should run fine on all cards that support OpenGL. If you have any problems or comments, please drop me a line - RottenTurd@earthlink.net .

** GL_RMISC.C: **

Near the top of the file, find this line:
   extern    cvar_t    gl_ztrick;
and add this just before it:
   cvar_t    gl_motionblur = {"gl_motionblur","0.55"};  //RottenTurd's motion blur


Next, just above the "R_RenderScene" function add these functions:

//RottenTurd's motion blur:
void OrthoMode(int left, int top, int right, int bottom)
{
   glMatrixMode(GL_PROJECTION);                       
   glPushMatrix();                                   
   glLoadIdentity();                              
   glOrtho( left, right, bottom, top, 0, 1 );   
   glMatrixMode(GL_MODELVIEW);                               
   glLoadIdentity();                                     
}

void PerspectiveMode()
{
   glMatrixMode( GL_PROJECTION );                           
   glPopMatrix();                                           
   glMatrixMode( GL_MODELVIEW );                           
}

void R_RenderMotionBlur()
{
   glPushMatrix();   
       glDisable(GL_DEPTH_TEST);           
       glDisable (GL_CULL_FACE);
       glBlendFunc(GL_ZERO, GL_SRC_ALPHA);
       glEnable(GL_BLEND);   
       glBindTexture(GL_TEXTURE_2D, 0);
       glColor4f(1, 1, 1, gl_motionblur.value);
       OrthoMode(0, 0, vid.width, vid.height);
       glBegin(GL_QUADS);       
         glTexCoord2f(0.0f, 1.0f);    glVertex2f(0, 0);
        glTexCoord2f(0.0f, 0.0f);    glVertex2f(0, vid.height);
        glTexCoord2f(1.0f, 0.0f);    glVertex2f(vid.width, vid.height);
        glTexCoord2f(1.0f, 1.0f);    glVertex2f(vid.width, 0);
       glEnd();       
       PerspectiveMode();       
       glEnable(GL_DEPTH_TEST);
       glEnable (GL_CULL_FACE);

       //RottenTurd: reset view here:
           glLoadIdentity();
           glRotatef (-90, 1, 0, 0);
           glRotatef (90, 0, 0, 1);
           glRotatef (-r_refdef.viewangles[2],  1, 0, 0);
           glRotatef (-r_refdef.viewangles[0],  0, 1, 0);
           glRotatef (-r_refdef.viewangles[1],  0, 0, 1);
           glTranslatef (-r_refdef.vieworg[0],  -r_refdef.vieworg[1],  -r_refdef.vieworg[2]);

       R_DrawWorld ();
       glDisable(GL_BLEND);                                       
   glPopMatrix();
}


Then, in the R_RenderScene function, replace this line:
   R_DrawWorld ();        // adds static entities to the list
with these two lines:
   if(gl_motionblur.value > 0)    R_RenderMotionBlur();  //RottenTurd's motion blur
   else R_DrawWorld();  //adds static entities to the list


** In the GL_RMISC.C file **

In the R_Init function find this line:
   R_InitParticles ();
and add this line right before it:
   Cvar_RegisterVariable (&gl_motionblur);  //RottenTurd's motion blur



** In the GLQUAKE.H file **

Find this line:
   extern    int        gl_lightmap_format;
and add this line right before it:
   extern    cvar_t    gl_motionblur;  // RottenTurd - Motion Blur variable



** In GL_RSURF.C **

In the "R_RecursiveWorldNode" function, find this part near the end of the function:

   } else
       R_DrawSequentialPoly (surf);

and make it look like this:
   } else{
       glColor4f(1.0f,1.0f,1.0f, 0.5f);  //RottenTurd: sets texture brightness
       glBlendFunc(GL_SRC_ALPHA,GL_ONE);
       R_DrawSequentialPoly (surf);
   }


Now you should be ready to compile it and check it out.  You can change the amount of blur by typing "gl_motionblur" at the console, followed by a number between 0 and 1; the default is 0.55.