From 19a3a38b1c030720d375f0861b747ab219c0e9ea Mon Sep 17 00:00:00 2001 From: samual Date: Sun, 13 Sep 2009 15:23:25 +0000 Subject: [PATCH] remove r_motionblur_debug, and replace with showblur which has been added to sbar.c git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@9189 d7cf8633-e32d-0410-b094-e92efae38249 --- client.h | 3 +++ gl_rmain.c | 23 ++++++++--------------- sbar.c | 17 +++++++++++++++-- 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/client.h b/client.h index a8ed8344..fc13bae0 100644 --- a/client.h +++ b/client.h @@ -893,6 +893,9 @@ typedef struct client_state_s // 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; diff --git a/gl_rmain.c b/gl_rmain.c index 23351c76..32014b33 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -43,7 +43,6 @@ cvar_t r_motionblur_bmin = {CVAR_SAVE, "r_motionblur_bmin", "0.5", "velocity at 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"}; @@ -2408,7 +2407,6 @@ void GL_Main_Init(void) 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); @@ -3772,22 +3770,21 @@ static void R_BlendView(void) 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) + @@ -3797,18 +3794,14 @@ static void R_BlendView(void) 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); diff --git a/sbar.c b/sbar.c index d98a4487..d93f0304 100644 --- a/sbar.c +++ b/sbar.c @@ -90,6 +90,7 @@ cachepic_t *sb_finale; 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)"}; @@ -378,6 +379,7 @@ void Sbar_Init (void) 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); @@ -1096,6 +1098,7 @@ void Sbar_ShowFPS(void) char timestring[32]; char datestring[32]; char speedstring[32]; + char blurstring[32]; char topspeedstring[48]; qboolean red = false; soundstring[0] = 0; @@ -1103,6 +1106,7 @@ void Sbar_ShowFPS(void) timestring[0] = 0; datestring[0] = 0; speedstring[0] = 0; + blurstring[0] = 0; topspeedstring[0] = 0; if (showfps.integer) { @@ -1137,6 +1141,8 @@ void Sbar_ShowFPS(void) 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) @@ -1175,11 +1181,11 @@ void Sbar_ShowFPS(void) 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; @@ -1228,6 +1234,13 @@ void Sbar_ShowFPS(void) 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; + } } } -- 2.39.2