]> de.git.xonotic.org Git - voretournament/voretournament.git/blobdiff - data/qcsrc/client/View.qc
Add a permanent post-processing cartoon effect (previously visible when you had the...
[voretournament/voretournament.git] / data / qcsrc / client / View.qc
index e5104c4e780cad88952b450b9a3024a8f96a2cc5..113d8c5423b290f4ca6ed6fd447cac7c92599481 100644 (file)
@@ -253,7 +253,7 @@ float pickup_crosshair_time, pickup_crosshair_size, pickup_flash_time, vore_flas
 float spawnfov_current;\r
 float myhealth, myhealth_prev, myhealth_flash;\r
 float contentavgalpha, liquidalpha_prev;\r
-float old_blurradius, old_bluralpha, old_sharpen_intensity;\r
+float old_blurradius, old_bluralpha, old_cartoon_intensity;\r
 float stomachsplash_alpha;\r
 float volume_modify_1, volume_modify_2, volume_modify_default_1, volume_modify_default_2;\r
 float volume_modify_changed_1, volume_modify_changed_2;\r
@@ -882,8 +882,8 @@ void CSQC_UpdateView(float w, float h)
                // enable or disable rendering types if they are used or not\r
                if(cvar("r_glsl_postprocess_uservec1_enable") != (cvar("hud_postprocessing_maxbluralpha") != 0))\r
                        cvar_set("r_glsl_postprocess_uservec1_enable", ftos(cvar("hud_postprocessing_maxbluralpha") != 0));\r
-               if(cvar("r_glsl_postprocess_uservec2_enable") != (cvar("hud_powerup") != 0))\r
-                       cvar_set("r_glsl_postprocess_uservec2_enable", ftos(cvar("hud_powerup") != 0));\r
+               if(cvar("r_glsl_postprocess_uservec2_enable") != (cvar("hud_cartoon") != 0))\r
+                       cvar_set("r_glsl_postprocess_uservec2_enable", ftos(cvar("hud_cartoon") != 0));\r
 \r
                // lets apply the postprocess effects from the previous two functions if needed\r
                if((damage_blurpostprocess_x || content_blurpostprocess_x) && cvar("chase_active") >= 0) // not while the event chase camera is active\r
@@ -904,26 +904,27 @@ void CSQC_UpdateView(float w, float h)
                        old_bluralpha = 0;\r
                }\r
 \r
-               float sharpen_intensity;\r
-               if (getstatf(STAT_STRENGTH_FINISHED) - time > 0)\r
-                       sharpen_intensity += (getstatf(STAT_STRENGTH_FINISHED) - time);\r
-               if (getstatf(STAT_INVINCIBLE_FINISHED) - time > 0)\r
-                       sharpen_intensity += (getstatf(STAT_INVINCIBLE_FINISHED) - time);\r
-\r
-               if(cvar("hud_powerup") && sharpen_intensity > 0 && cvar("chase_active") >= 0) // not while the event chase camera is active\r
+               if(cvar("hud_cartoon"))\r
                {\r
-                       sharpen_intensity = bound(0, sharpen_intensity, 5); // powerup warning time is 5 seconds, so fade the effect from there\r
-\r
-                       if(sharpen_intensity != old_sharpen_intensity) // reduce cvar_set spam as much as possible\r
+                       // When having the strength or invincible powerups, cartoon lines will be white instead of black.\r
+                       // As powerup time goes under 5 seconds (warning time), lines will fade from white to nothing then from nothing back to black.\r
+                       float cartoon_intensity, cartoon_powerup;\r
+                       cartoon_intensity = -cvar("hud_cartoon");\r
+                       cartoon_powerup = bound(0, getstatf(STAT_STRENGTH_FINISHED) - time, 5) + bound(0, getstatf(STAT_INVINCIBLE_FINISHED) - time, 5);\r
+                       cartoon_powerup = bound(0, cartoon_powerup, 5);\r
+                       if (cartoon_powerup && cvar("chase_active") >= 0) // not while the event chase camera is active\r
+                               cartoon_intensity *= 1 - cartoon_powerup / 2.5; // cycle between -1 and 1\r
+\r
+                       if(cartoon_intensity != old_cartoon_intensity) // reduce cvar_set spam as much as possible\r
                        {\r
-                               cvar_set("r_glsl_postprocess_uservec2", strcat("0 ", ftos(-sharpen_intensity * cvar("hud_powerup")), " 0 0"));\r
-                               old_sharpen_intensity = sharpen_intensity;\r
+                               cvar_set("r_glsl_postprocess_uservec2", strcat("0 ", ftos(cartoon_intensity), " ", cvar_string("hud_cartoon_tolerance"), " 0"));\r
+                               old_cartoon_intensity = cartoon_intensity;\r
                        }\r
                }\r
                else if(cvar_string("r_glsl_postprocess_uservec2") != "0 0 0 0") // reduce cvar_set spam as much as possible\r
                {\r
                        cvar_set("r_glsl_postprocess_uservec2", "0 0 0 0");\r
-                       old_sharpen_intensity = 0;\r
+                       old_cartoon_intensity = 0;\r
                }\r
        }\r
 \r
@@ -934,7 +935,7 @@ void CSQC_UpdateView(float w, float h)
                cvar_set("r_glsl_postprocess_uservec1", "0 0 0 0");\r
                cvar_set("r_glsl_postprocess_uservec1_enable", "0");\r
        }\r
-       if(cvar("hud_postprocessing") && !cvar("hud_powerup"))\r
+       if(cvar("hud_postprocessing") && !cvar("hud_cartoon"))\r
        if(cvar("r_glsl_postprocess_uservec2_enable"))\r
        {\r
                // don't allow sharpen to get stuck on if we disable the cvar while powered up\r