// fade var for fading while dead
float deathfade;
+ // motionblur alpha level variable
+ float motionbluralpha;
+
// copy of realtime from last recieved message, for net trouble icon
float last_received_message;
cvar_t r_motionblur_vcoeff = {CVAR_SAVE, "r_motionblur_vcoeff", "0.05", "sliding average reaction time for velocity"};
cvar_t r_motionblur_maxblur = {CVAR_SAVE, "r_motionblur_maxblur", "0.88", "cap for motionblur alpha value"};
cvar_t r_motionblur_randomize = {CVAR_SAVE, "r_motionblur_randomize", "0.1", "randomizing coefficient to workaround ghosting"};
-cvar_t r_motionblur_debug = {0, "r_motionblur_debug", "0", "outputs current motionblur alpha value"};
cvar_t r_animcache = {CVAR_SAVE, "r_animcache", "1", "cache animation frames to save CPU usage, primarily optimizes shadows and reflections"};
Cvar_RegisterVariable(&r_motionblur_randomize);
Cvar_RegisterVariable(&r_damageblur);
Cvar_RegisterVariable(&r_animcache);
- Cvar_RegisterVariable(&r_motionblur_debug);
Cvar_RegisterVariable(&r_depthfirst);
Cvar_RegisterVariable(&r_useinfinitefarclip);
Cvar_RegisterVariable(&r_nearclip);
if(!R_Stereo_Active() && (r_motionblur.value > 0 || r_damageblur.value > 0))
{
- // declare alpha variable
- float a;
+ // declare variables
float speed;
static float avgspeed;
speed = VectorLength(cl.movement_velocity);
- a = bound(0, (cl.time - cl.oldtime) / max(0.001, r_motionblur_vcoeff.value), 1);
- avgspeed = avgspeed * (1 - a) + speed * a;
+ cl.motionbluralpha = bound(0, (cl.time - cl.oldtime) / max(0.001, r_motionblur_vcoeff.value), 1);
+ avgspeed = avgspeed * (1 - cl.motionbluralpha) + speed * cl.motionbluralpha;
speed = (avgspeed - r_motionblur_vmin.value) / max(1, r_motionblur_vmax.value - r_motionblur_vmin.value);
speed = bound(0, speed, 1);
speed = speed * (1 - r_motionblur_bmin.value) + r_motionblur_bmin.value;
// calculate values into a standard alpha
- a = 1 - exp(-
+ cl.motionbluralpha = 1 - exp(-
(
(r_motionblur.value * speed / 80)
+
max(0.0001, cl.time - cl.oldtime) // fps independent
);
- a *= lhrandom(1 - r_motionblur_randomize.value, 1 + r_motionblur_randomize.value);
- a = bound(0, a, r_motionblur_maxblur.value);
-
- // developer debug of current value
- if (r_motionblur_debug.value) { Con_Printf("blur alpha = %f\n", a); }
-
+ cl.motionbluralpha *= lhrandom(1 - r_motionblur_randomize.value, 1 + r_motionblur_randomize.value);
+ cl.motionbluralpha = bound(0, cl.motionbluralpha, r_motionblur_maxblur.value);
// apply the blur
- if (a > 0)
+ if (cl.motionbluralpha > 0)
{
R_SetupGenericShader(true);
GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- GL_Color(1, 1, 1, a); // to do: add color changing support for damage blur
+ GL_Color(1, 1, 1, cl.motionbluralpha);
R_Mesh_TexBind(0, R_GetTexture(r_bloomstate.texture_screen));
R_Mesh_TexCoordPointer(0, 2, r_bloomstate.screentexcoord2f, 0, 0);
R_Mesh_Draw(0, 4, 0, 2, NULL, polygonelements, 0, 0);
cvar_t showfps = {CVAR_SAVE, "showfps", "0", "shows your rendered fps (frames per second)"};
cvar_t showsound = {CVAR_SAVE, "showsound", "0", "shows number of active sound sources, sound latency, and other statistics"};
+cvar_t showblur = {CVAR_SAVE, "showblur", "0", "shows the current alpha level of motionblur"};
cvar_t showspeed = {CVAR_SAVE, "showspeed", "0", "shows your current speed (qu per second); number selects unit: 1 = qu/s, 2 = m/s, 3 = km/h, 4 = mph, 5 = knots"};
cvar_t showtopspeed = {CVAR_SAVE, "showtopspeed", "0", "shows your top speed (kept on screen for max 3 seconds); value -1 takes over the unit from showspeed, otherwise it's an unit number just like in showspeed"};
cvar_t showtime = {CVAR_SAVE, "showtime", "0", "shows current time of day (useful on screenshots)"};
Cmd_AddCommand("-showscores", Sbar_DontShowScores, "hide scoreboard");
Cvar_RegisterVariable(&showfps);
Cvar_RegisterVariable(&showsound);
+ Cvar_RegisterVariable(&showblur);
Cvar_RegisterVariable(&showspeed);
Cvar_RegisterVariable(&showtopspeed);
Cvar_RegisterVariable(&showtime);
char timestring[32];
char datestring[32];
char speedstring[32];
+ char blurstring[32];
char topspeedstring[48];
qboolean red = false;
soundstring[0] = 0;
timestring[0] = 0;
datestring[0] = 0;
speedstring[0] = 0;
+ blurstring[0] = 0;
topspeedstring[0] = 0;
if (showfps.integer)
{
strlcpy(timestring, Sys_TimeString(showtime_format.string), sizeof(timestring));
if (showdate.integer)
strlcpy(datestring, Sys_TimeString(showdate_format.string), sizeof(datestring));
+ if (showblur.integer)
+ dpsnprintf(blurstring, sizeof(blurstring), "%3i%% blur", (int)(cl.motionbluralpha * 100));
if (showsound.integer)
dpsnprintf(soundstring, sizeof(soundstring), "%4i/4%i at %3ims", cls.soundstats.mixedsounds, cls.soundstats.totalsounds, cls.soundstats.latency_milliseconds);
if (showspeed.integer || showtopspeed.integer)
time(¤t_time);
}
}
- if (fpsstring[0] || timestring[0] || datestring[0] || speedstring[0] || topspeedstring[0])
+ if (fpsstring[0] || timestring[0] || datestring[0] || speedstring[0] || blurstring[0] || topspeedstring[0])
{
fps_scalex = 12;
fps_scaley = 12;
- fps_height = fps_scaley * ((soundstring[0] != 0) + (fpsstring[0] != 0) + (timestring[0] != 0) + (datestring[0] != 0) + (speedstring[0] != 0) + (topspeedstring[0] != 0));
+ fps_height = fps_scaley * ((soundstring[0] != 0) + (blurstring[0] != 0) + (fpsstring[0] != 0) + (timestring[0] != 0) + (datestring[0] != 0) + (speedstring[0] != 0) + (topspeedstring[0] != 0));
//fps_y = vid_conheight.integer - sb_lines; // yes this may draw over the sbar
//fps_y = bound(0, fps_y, vid_conheight.integer - fps_height);
fps_y = vid_conheight.integer - sbar_info_pos.integer - fps_height;
DrawQ_String_Font(fps_x, fps_y, topspeedstring, 0, fps_scalex, fps_scaley, 1, 1, 1, 1, 0, NULL, false, FONT_INFOBAR);
fps_y += fps_scaley;
}
+ if (blurstring[0])
+ {
+ fps_x = vid_conwidth.integer - DrawQ_TextWidth_Font(blurstring, 0, true, FONT_INFOBAR) * fps_scalex;
+ DrawQ_Fill(fps_x, fps_y, vid_conwidth.integer - fps_x, fps_scaley, 0, 0, 0, 0.5, 0);
+ DrawQ_String_Font(fps_x, fps_y, blurstring, 0, fps_scalex, fps_scaley, 1, 1, 1, 1, 0, NULL, true, FONT_INFOBAR);
+ fps_y += fps_scaley;
+ }
}
}