Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: gl_rmain.c
- ===================================================================
- --- gl_rmain.c (revision 9017)
- +++ gl_rmain.c (working copy)
- @@ -35,6 +35,13 @@
- //
- r_refdef_t r_refdef;
- +cvar_t r_motionblur = {CVAR_SAVE, "r_motionblur", "0", "motionblur frame-by-frame alpha control {0 to 1} - 0.7 recommended"};
- +cvar_t r_damageblur = {CVAR_SAVE, "r_damageblur", "0", "motionblur based on damage; requires r_motionblur to have a value"};
- +cvar_t r_motionblur_adj = {CVAR_SAVE, "r_motionblur_adj", "0.000015", "motionblur fps adjustment value - do not change unless you know what you're doing"};
- +cvar_t r_motionblur_min = {CVAR_SAVE, "r_motionblur_min", "0.3", "motionblur velocity minimum - do not change unless you know what you're doing"};
- +cvar_t r_motionblur_max = {CVAR_SAVE, "r_motionblur_max", "0.6", "motionblur velocity maximum - do not change unless you know what you're doing"};
- +cvar_t r_motionblur_debug = {0, "r_motionblur_debug", "0", "testing motionblur - developer tool"};
- +
- cvar_t r_depthfirst = {CVAR_SAVE, "r_depthfirst", "0", "renders a depth-only version of the scene before normal rendering begins to eliminate overdraw, values: 0 = off, 1 = world depth, 2 = world and model depth"};
- cvar_t r_useinfinitefarclip = {CVAR_SAVE, "r_useinfinitefarclip", "1", "enables use of a special kind of projection matrix that has an extremely large farclip"};
- cvar_t r_nearclip = {0, "r_nearclip", "1", "distance from camera of nearclip plane" };
- @@ -142,7 +149,7 @@
- int bloomwidth, bloomheight;
- int screentexturewidth, screentextureheight;
- - rtexture_t *texture_screen;
- + rtexture_t *texture_screen; // also used for motion blur if enabled!
- int bloomtexturewidth, bloomtextureheight;
- rtexture_t *texture_bloom;
- @@ -2376,6 +2383,12 @@
- Cvar_RegisterVariable (&gl_fogend);
- Cvar_RegisterVariable (&gl_skyclip);
- }
- + Cvar_RegisterVariable(&r_motionblur);
- + Cvar_RegisterVariable(&r_motionblur_adj);
- + Cvar_RegisterVariable(&r_motionblur_min);
- + Cvar_RegisterVariable(&r_motionblur_max);
- + Cvar_RegisterVariable(&r_damageblur);
- + Cvar_RegisterVariable(&r_motionblur_debug);
- Cvar_RegisterVariable(&r_depthfirst);
- Cvar_RegisterVariable(&r_useinfinitefarclip);
- Cvar_RegisterVariable(&r_nearclip);
- @@ -3318,13 +3331,14 @@
- for (bloomtextureheight = 1;bloomtextureheight < r_bloomstate.bloomheight;bloomtextureheight *= 2);
- }
- - if ((r_hdr.integer || r_bloom.integer) && ((r_bloom_resolution.integer < 4 || r_bloom_blur.value < 1 || r_bloom_blur.value >= 512) || r_refdef.view.width > gl_max_texture_size || r_refdef.view.height > gl_max_texture_size))
- + if ((r_hdr.integer || r_bloom.integer || r_motionblur.value) && ((r_bloom_resolution.integer < 4 || r_bloom_blur.value < 1 || r_bloom_blur.value >= 512) || r_refdef.view.width > gl_max_texture_size || r_refdef.view.height > gl_max_texture_size))
- {
- Cvar_SetValueQuick(&r_hdr, 0);
- Cvar_SetValueQuick(&r_bloom, 0);
- + Cvar_SetValueQuick(&r_motionblur, 0);
- }
- - if (!(r_glsl.integer && (r_glsl_postprocess.integer || r_glsl_saturation.value != 1 || (v_glslgamma.integer && !vid_gammatables_trivial) || r_bloom.integer || r_hdr.integer)) && !r_bloom.integer)
- + if (!(r_glsl.integer && (r_glsl_postprocess.integer || (v_glslgamma.integer && !vid_gammatables_trivial))) && !r_bloom.integer && !r_hdr.integer && !r_motionblur.value)
- screentexturewidth = screentextureheight = 0;
- if (!r_hdr.integer && !r_bloom.integer)
- bloomtexturewidth = bloomtextureheight = 0;
- @@ -3580,12 +3594,55 @@
- {
- if (r_bloomstate.texture_screen)
- {
- - // copy view into the screen texture
- + r_motionblur.value = bound(0.0, r_motionblur.value, 1.0);
- + r_damageblur.value = bound(0.0, r_damageblur.value, 1.0);
- + r_motionblur_min.value = bound(0.0, r_motionblur_min.value, 1.0);
- + r_motionblur_max.value = bound(0.0, r_motionblur_max.value, 1.0);
- R_ResetViewRendering2D();
- R_Mesh_VertexPointer(r_screenvertex3f, 0, 0);
- R_Mesh_ColorPointer(NULL, 0, 0);
- R_Mesh_TexBind(0, R_GetTexture(r_bloomstate.texture_screen));
- GL_ActiveTexture(0);CHECKGLERROR
- + if(r_motionblur.value)
- + {
- + double rspeed = bound(r_motionblur_min.value,(sqrt(cl.movement_velocity[0] * cl.movement_velocity[0] + cl.movement_velocity[1] * cl.movement_velocity[1]) / 1000),r_motionblur_max.value);
- + float a;
- + float calc;
- + static double nexttime = 0, lasttime = 0;
- + static double framerate = 0;
- + static int framecount = 0;
- + double interval = 0.25;
- + double newtime;
- + newtime = realtime;
- + if (newtime >= nexttime)
- + {
- + framerate = framecount / (newtime - lasttime);
- + if (nexttime < newtime - interval * 1.5)
- + nexttime = newtime;
- + lasttime = newtime;
- + nexttime += interval;
- + framecount = 0;
- + }
- + framecount++;
- + calc = framerate;
- + a = exp( - (1 / (calc + 0.5)) / (((r_motionblur.value / 25) * rspeed) + (r_damageblur.value * (cl.cshifts[CSHIFT_DAMAGE].percent / 300)) - ((calc + 0.5) * r_motionblur_adj.value)));
- + //1.0f - cl.realframetime / (((r_motionblur.value / 15) * rspeed) + (r_damageblur.value * (cl.cshifts[CSHIFT_DAMAGE].percent / 300)));
- + if (r_motionblur_debug.value) { Con_Printf("rft - fpsm is %f\n", cl.realframetime - (1 / (calc + 0.5))); }
- + if (a > 0)
- + {
- + //a = (a * bound(0.5,(speedxy / 1000),1)) + (r_damageblur.value * (cl.cshifts[CSHIFT_DAMAGE].percent / 300));
- + R_SetupGenericShader(true);
- + GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- + GL_Color(1, 1, 1, a);
- + 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);
- + r_refdef.stats.bloom_drawpixels += r_refdef.view.width * r_refdef.view.height;
- +
- + }
- + }
- +
- + // copy view into the screen texture
- qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, r_refdef.view.x, vid.height - (r_refdef.view.y + r_refdef.view.height), r_refdef.view.width, r_refdef.view.height);CHECKGLERROR
- r_refdef.stats.bloom_copypixels += r_refdef.view.width * r_refdef.view.height;
- }
- @@ -3984,7 +4041,7 @@
- R_RenderScene();
- r_waterstate.numwaterplanes = 0;
- -
- +
- R_BlendView();
- if (r_timereport_active)
- R_TimeReport("blendview");
Add Comment
Please, Sign In to add comment