Guest User

Untitled

a guest
Jun 21st, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.69 KB | None | 0 0
  1. *** gl_rmain.c 2009-04-05 06:32:22.000000000 -0400
  2.  
  3. --- gl_rmain.c 2009-06-13 12:44:06.881000000 -0400
  4.  
  5. ***************
  6.  
  7. *** 35,40 ****
  8.  
  9. --- 35,48 ----
  10.  
  11. //
  12.  
  13. r_refdef_t r_refdef;
  14.  
  15.  
  16.  
  17. + cvar_t r_motionblur = {CVAR_SAVE, "r_motionblur", "0", "motionblur frame-by-frame alpha control {0 to 1} - 0.7 recommended"};
  18.  
  19. + cvar_t r_damageblur = {CVAR_SAVE, "r_damageblur", "0", "motionblur based on damage; requires r_motionblur to have a value"};
  20.  
  21. + cvar_t r_motionblur_maxblur = {CVAR_SAVE, "r_motionblur_maxblur", "0.88", "cap for the alpha level of the motion blur variable"};
  22.  
  23. + 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"};
  24.  
  25. + 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"};
  26.  
  27. + 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"};
  28.  
  29. + cvar_t r_motionblur_debug = {0, "r_motionblur_debug", "0", "outputs current motionblur alpha value"};
  30.  
  31. +
  32.  
  33. 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"};
  34.  
  35. cvar_t r_useinfinitefarclip = {CVAR_SAVE, "r_useinfinitefarclip", "1", "enables use of a special kind of projection matrix that has an extremely large farclip"};
  36.  
  37. cvar_t r_nearclip = {0, "r_nearclip", "1", "distance from camera of nearclip plane" };
  38.  
  39. ***************
  40.  
  41. *** 141,147 ****
  42.  
  43. int bloomwidth, bloomheight;
  44.  
  45.  
  46.  
  47. int screentexturewidth, screentextureheight;
  48.  
  49. ! rtexture_t *texture_screen;
  50.  
  51.  
  52.  
  53. int bloomtexturewidth, bloomtextureheight;
  54.  
  55. rtexture_t *texture_bloom;
  56.  
  57. --- 149,155 ----
  58.  
  59. int bloomwidth, bloomheight;
  60.  
  61.  
  62.  
  63. int screentexturewidth, screentextureheight;
  64.  
  65. ! rtexture_t *texture_screen; // also used for motion blur if enabled!
  66.  
  67.  
  68.  
  69. int bloomtexturewidth, bloomtextureheight;
  70.  
  71. rtexture_t *texture_bloom;
  72.  
  73. ***************
  74.  
  75. *** 2362,2367 ****
  76.  
  77. --- 2370,2382 ----
  78.  
  79. Cvar_RegisterVariable (&gl_fogend);
  80.  
  81. Cvar_RegisterVariable (&gl_skyclip);
  82.  
  83. }
  84.  
  85. + Cvar_RegisterVariable(&r_motionblur);
  86.  
  87. + Cvar_RegisterVariable(&r_motionblur_adj);
  88.  
  89. + Cvar_RegisterVariable(&r_motionblur_vmin);
  90.  
  91. + Cvar_RegisterVariable(&r_motionblur_vmax);
  92.  
  93. + Cvar_RegisterVariable(&r_motionblur_maxblur);
  94.  
  95. + Cvar_RegisterVariable(&r_damageblur);
  96.  
  97. + Cvar_RegisterVariable(&r_motionblur_debug);
  98.  
  99. Cvar_RegisterVariable(&r_depthfirst);
  100.  
  101. Cvar_RegisterVariable(&r_useinfinitefarclip);
  102.  
  103. Cvar_RegisterVariable(&r_nearclip);
  104.  
  105. ***************
  106.  
  107. *** 3303,3315 ****
  108.  
  109. for (bloomtextureheight = 1;bloomtextureheight < r_bloomstate.bloomheight;bloomtextureheight *= 2);
  110.  
  111. }
  112.  
  113.  
  114.  
  115. ! 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))
  116.  
  117. {
  118.  
  119. Cvar_SetValueQuick(&r_hdr, 0);
  120.  
  121. Cvar_SetValueQuick(&r_bloom, 0);
  122.  
  123. }
  124.  
  125.  
  126.  
  127. ! if (!(r_glsl.integer && (r_glsl_postprocess.integer || (v_glslgamma.integer && !vid_gammatables_trivial) || r_bloom.integer || r_hdr.integer)) && !r_bloom.integer)
  128.  
  129. screentexturewidth = screentextureheight = 0;
  130.  
  131. if (!r_hdr.integer && !r_bloom.integer)
  132.  
  133. bloomtexturewidth = bloomtextureheight = 0;
  134.  
  135. --- 3318,3331 ----
  136.  
  137. for (bloomtextureheight = 1;bloomtextureheight < r_bloomstate.bloomheight;bloomtextureheight *= 2);
  138.  
  139. }
  140.  
  141.  
  142.  
  143. ! 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))
  144.  
  145. {
  146.  
  147. Cvar_SetValueQuick(&r_hdr, 0);
  148.  
  149. Cvar_SetValueQuick(&r_bloom, 0);
  150.  
  151. + //Cvar_SetValueQuick(&r_motionblur, 0);
  152.  
  153. }
  154.  
  155.  
  156.  
  157. ! if (!(r_glsl.integer && (r_glsl_postprocess.integer || (v_glslgamma.integer && !vid_gammatables_trivial))) && !r_bloom.integer && !r_hdr.integer && !r_motionblur.value)
  158.  
  159. screentexturewidth = screentextureheight = 0;
  160.  
  161. if (!r_hdr.integer && !r_bloom.integer)
  162.  
  163. bloomtexturewidth = bloomtextureheight = 0;
  164.  
  165. ***************
  166.  
  167. *** 3565,3576 ****
  168.  
  169. {
  170.  
  171. if (r_bloomstate.texture_screen)
  172.  
  173. {
  174.  
  175. ! // copy view into the screen texture
  176.  
  177. R_ResetViewRendering2D();
  178.  
  179. R_Mesh_VertexPointer(r_screenvertex3f, 0, 0);
  180.  
  181. R_Mesh_ColorPointer(NULL, 0, 0);
  182.  
  183. R_Mesh_TexBind(0, R_GetTexture(r_bloomstate.texture_screen));
  184.  
  185. GL_ActiveTexture(0);CHECKGLERROR
  186.  
  187. 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
  188.  
  189. r_refdef.stats.bloom_copypixels += r_refdef.view.width * r_refdef.view.height;
  190.  
  191. }
  192.  
  193. --- 3581,3642 ----
  194.  
  195. {
  196.  
  197. if (r_bloomstate.texture_screen)
  198.  
  199. {
  200.  
  201. ! // make sure the buffer is available
  202.  
  203. ! if (r_bloom_blur.value < 1) { Cvar_SetValueQuick(&r_bloom_blur, 1); }
  204.  
  205. ! // force main variables to a limited value
  206.  
  207. ! if (r_motionblur.value > 1 || r_motionblur.value < 0) { Cvar_SetValueQuick(&r_motionblur,bound(0.0, r_motionblur.value, 1.0)); }
  208.  
  209. ! if (r_damageblur.value > 1 || r_damageblur.value < 0) { Cvar_SetValueQuick(&r_damageblur,bound(0.0, r_damageblur.value, 1.0)); }
  210.  
  211. ! 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)); }
  212.  
  213. ! 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)); }
  214.  
  215. ! 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)); }
  216.  
  217. R_ResetViewRendering2D();
  218.  
  219. R_Mesh_VertexPointer(r_screenvertex3f, 0, 0);
  220.  
  221. R_Mesh_ColorPointer(NULL, 0, 0);
  222.  
  223. R_Mesh_TexBind(0, R_GetTexture(r_bloomstate.texture_screen));
  224.  
  225. GL_ActiveTexture(0);CHECKGLERROR
  226.  
  227. + if(r_motionblur.value)
  228.  
  229. + {
  230.  
  231. + // determin current velocity on X Y Z
  232.  
  233. + double rspeed = bound(r_motionblur_vmin.value,(VectorLength(cl.movement_velocity) / 1000),r_motionblur_vmax.value);
  234.  
  235. + // declare alpha variable
  236.  
  237. + float a;
  238.  
  239. + // determin current fps
  240.  
  241. + float calc;
  242.  
  243. + static double nexttime = 0, lasttime = 0;
  244.  
  245. + static double framerate = 0;
  246.  
  247. + static int framecount = 0;
  248.  
  249. + double interval = 0.25;
  250.  
  251. + double newtime;
  252.  
  253. + newtime = realtime;
  254.  
  255. + if (newtime >= nexttime)
  256.  
  257. + {
  258.  
  259. + framerate = framecount / (newtime - lasttime);
  260.  
  261. + if (nexttime < newtime - interval * 1.5)
  262.  
  263. + nexttime = newtime;
  264.  
  265. + lasttime = newtime;
  266.  
  267. + nexttime += interval;
  268.  
  269. + framecount = 0;
  270.  
  271. + }
  272.  
  273. + framecount++;
  274.  
  275. + calc = framerate;
  276.  
  277. + // calculate values into a standard alpha
  278.  
  279. + 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);
  280.  
  281. + // developer debug of current value
  282.  
  283. + if (r_motionblur_debug.value) { Con_Printf("blur level is %f\n", a); }
  284.  
  285. + // apply the blur
  286.  
  287. + if (a > 0)
  288.  
  289. + {
  290.  
  291. + R_SetupGenericShader(true);
  292.  
  293. + GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  294.  
  295. + GL_Color(1, 1, 1, a); // to do: add color changing support for damage blur
  296.  
  297. + R_Mesh_TexBind(0, R_GetTexture(r_bloomstate.texture_screen));
  298.  
  299. + R_Mesh_TexCoordPointer(0, 2, r_bloomstate.screentexcoord2f, 0, 0);
  300.  
  301. + R_Mesh_Draw(0, 4, 0, 2, NULL, polygonelements, 0, 0);
  302.  
  303. + r_refdef.stats.bloom_drawpixels += r_refdef.view.width * r_refdef.view.height;
  304.  
  305. + }
  306.  
  307. + }
  308.  
  309. +
  310.  
  311. + // copy view into the screen texture
  312.  
  313. 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
  314.  
  315. r_refdef.stats.bloom_copypixels += r_refdef.view.width * r_refdef.view.height;
  316.  
  317. }
  318.  
  319. ***************
  320.  
  321. *** 3966,3972 ****
  322.  
  323.  
  324.  
  325. R_RenderScene();
  326.  
  327. r_waterstate.numwaterplanes = 0;
  328.  
  329. !
  330.  
  331. R_BlendView();
  332.  
  333. if (r_timereport_active)
  334.  
  335. R_TimeReport("blendview");
  336.  
  337. --- 4032,4038 ----
  338.  
  339.  
  340.  
  341. R_RenderScene();
  342.  
  343. r_waterstate.numwaterplanes = 0;
  344.  
  345. !
  346.  
  347. R_BlendView();
  348.  
  349. if (r_timereport_active)
  350.  
  351. R_TimeReport("blendview");
Add Comment
Please, Sign In to add comment