Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- *** gl_rmain.c 2009-04-05 06:32:22.000000000 -0400
- --- gl_rmain.c 2009-06-13 12:44:06.881000000 -0400
- ***************
- *** 35,40 ****
- --- 35,48 ----
- //
- 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_maxblur = {CVAR_SAVE, "r_motionblur_maxblur", "0.88", "cap for the alpha level of the motion blur variable"};
- + 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_vmin = {CVAR_SAVE, "r_motionblur_vmin", "0.3", "motionblur velocity minimum - do not change unless you know what you're doing"};
- + cvar_t r_motionblur_vmax = {CVAR_SAVE, "r_motionblur_vmax", "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", "outputs current motionblur alpha value"};
- +
- 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" };
- ***************
- *** 141,147 ****
- int bloomwidth, bloomheight;
- int screentexturewidth, screentextureheight;
- ! rtexture_t *texture_screen;
- int bloomtexturewidth, bloomtextureheight;
- rtexture_t *texture_bloom;
- --- 149,155 ----
- int bloomwidth, bloomheight;
- int screentexturewidth, screentextureheight;
- ! rtexture_t *texture_screen; // also used for motion blur if enabled!
- int bloomtexturewidth, bloomtextureheight;
- rtexture_t *texture_bloom;
- ***************
- *** 2362,2367 ****
- --- 2370,2382 ----
- Cvar_RegisterVariable (&gl_fogend);
- Cvar_RegisterVariable (&gl_skyclip);
- }
- + Cvar_RegisterVariable(&r_motionblur);
- + Cvar_RegisterVariable(&r_motionblur_adj);
- + Cvar_RegisterVariable(&r_motionblur_vmin);
- + Cvar_RegisterVariable(&r_motionblur_vmax);
- + Cvar_RegisterVariable(&r_motionblur_maxblur);
- + Cvar_RegisterVariable(&r_damageblur);
- + Cvar_RegisterVariable(&r_motionblur_debug);
- Cvar_RegisterVariable(&r_depthfirst);
- Cvar_RegisterVariable(&r_useinfinitefarclip);
- Cvar_RegisterVariable(&r_nearclip);
- ***************
- *** 3303,3315 ****
- 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))
- {
- Cvar_SetValueQuick(&r_hdr, 0);
- Cvar_SetValueQuick(&r_bloom, 0);
- }
- ! if (!(r_glsl.integer && (r_glsl_postprocess.integer || (v_glslgamma.integer && !vid_gammatables_trivial) || r_bloom.integer || r_hdr.integer)) && !r_bloom.integer)
- screentexturewidth = screentextureheight = 0;
- if (!r_hdr.integer && !r_bloom.integer)
- bloomtexturewidth = bloomtextureheight = 0;
- --- 3318,3331 ----
- for (bloomtextureheight = 1;bloomtextureheight < r_bloomstate.bloomheight;bloomtextureheight *= 2);
- }
- ! 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 || (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;
- ***************
- *** 3565,3576 ****
- {
- if (r_bloomstate.texture_screen)
- {
- ! // copy view into the screen texture
- 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
- 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;
- }
- --- 3581,3642 ----
- {
- if (r_bloomstate.texture_screen)
- {
- ! // make sure the buffer is available
- ! if (r_bloom_blur.value < 1) { Cvar_SetValueQuick(&r_bloom_blur, 1); }
- ! // force main variables to a limited value
- ! if (r_motionblur.value > 1 || r_motionblur.value < 0) { Cvar_SetValueQuick(&r_motionblur,bound(0.0, r_motionblur.value, 1.0)); }
- ! if (r_damageblur.value > 1 || r_damageblur.value < 0) { Cvar_SetValueQuick(&r_damageblur,bound(0.0, r_damageblur.value, 1.0)); }
- ! if (r_motionblur_vmin.value > 1 || r_motionblur_vmin.value < 0) { Cvar_SetValueQuick(&r_motionblur_vmin,bound(0.0, r_motionblur_vmin.value, 1.0)); }
- ! if (r_motionblur_vmax.value > 1 || r_motionblur_vmax.value < 0) { Cvar_SetValueQuick(&r_motionblur_vmax,bound(0.0, r_motionblur_vmax.value, 1.0)); }
- ! if (r_motionblur_maxblur.value > 1 || r_motionblur_maxblur.value < 0) { Cvar_SetValueQuick(&r_motionblur_maxblur,bound(0.0, r_motionblur_maxblur.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)
- + {
- + // determin current velocity on X Y Z
- + double rspeed = bound(r_motionblur_vmin.value,(VectorLength(cl.movement_velocity) / 1000),r_motionblur_vmax.value);
- + // declare alpha variable
- + float a;
- + // determin current fps
- + 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;
- + // calculate values into a standard alpha
- + a = bound(0.0,(exp( - (1 / (calc + 0.5)) / (((r_motionblur.value / 25) * rspeed) + (r_damageblur.value * (cl.cshifts[CSHIFT_DAMAGE].percent / 500)) - ((calc + 0.5) * r_motionblur_adj.value)))),r_motionblur_maxblur.value);
- + // developer debug of current value
- + if (r_motionblur_debug.value) { Con_Printf("blur level is %f\n", a); }
- + // apply the blur
- + if (a > 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
- + 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;
- }
- ***************
- *** 3966,3972 ****
- R_RenderScene();
- r_waterstate.numwaterplanes = 0;
- !
- R_BlendView();
- if (r_timereport_active)
- R_TimeReport("blendview");
- --- 4032,4038 ----
- R_RenderScene();
- r_waterstate.numwaterplanes = 0;
- !
- R_BlendView();
- if (r_timereport_active)
- R_TimeReport("blendview");
Add Comment
Please, Sign In to add comment