Index | FAQ | Search | Memberlist | Usergroups | Profile | Log in to check your private messages | Log in | Register

Quake Motion Blur

| Inside3d Forums Forum Index -> Programming Tutorials

View previous topic :: View next topic
Author | Message
--- | ---
mh Joined: 12 Jan 2008 Posts: 910 |

Posted: Thu Apr 16, 2009 4:54 pm Post subject: Quake Motion Blur |

This somewhere in gl_rmain.c:

Code:
extern cvar_t r_motionblur; void DrawAccumBlur (void) { static int blurstate = 0; float accblur;
static float damagetime = -1.0f;
if (!r_motionblur.value) return;
// evaluate blur conditions
if (cl.stats[STAT_HEALTH] <= 0)
{
// being dead always overrides everything else
accblur = 0.75f;
}
else if (cl.cshifts[CSHIFT_DAMAGE].percent)
{
// initial damage blur
accblur = 0.75f;
damagetime = 0.5f;
}
else if (damagetime >= 0.0f)
{
// persist damage blur
damagetime -= r_frametime;
accblur = 0.75f;
}
else if (cl.cshifts[CSHIFT_CONTENTS].percent)
{
// blur less if underwater
accblur = 0.666f;
}
else accblur = -1.0f;
if (accblur <= 0.0f)
{
// reinit if we're not blurring so that the contents of the
// accumulation buffer are valid for the frame
blurstate = 0;
return;
}
if (!blurstate)
{
// load the scene into the accumulation buffer
glAccum (GL_LOAD, 1.0f);
}
else
{
glAccum (GL_MULT, accblur); // scale contents of accumulation buffer
glAccum (GL_ACCUM, 1.0f - accblur); // add screen contents
glAccum (GL_RETURN, 1.0f); // read result back
}
blurstate = 1;
}

(Declare and register the r_motionblur cvar somewhere too, and you may also need to have a global called r_frametime, so just set it up the same way as frametime in R_DrawParticles...)
Call it like this, at the end of R_RenderView, after everything else is drawn:

Code:
// draw motion blur effects on the full 3D view DrawAccumBlur ();

Finally, in gl_vidnt.c, when setting up your PIXELFORMATDESCRIPTOR, just set the cAccumBits member to 64.
There's no need to clear the accumulation buffer between frames, should work just fine on any engine out of the box.
_________________
DirectQ Engine - New release 1.8.666a, 9th August 2010
MHQuake Blog (General)
Direct3D 8 Quake Engines

Back to top |

MeTcHsteekle Joined: 15 May 2008 Posts: 397 Location: its a secret |

Posted: Thu Apr 16, 2009 5:47 pm Post subject: |

sweet _________________ bah

Back to top |

Display posts from previous:

| Inside3d Forums Forum Index -> Programming Tutorials | All times are GMT
Page 1 of 1

Jump to:

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB © 2004 phpBB Group