From: MirceaKitsune Date: Fri, 25 Feb 2011 21:21:04 +0000 (+0200) Subject: Blur postprocessing effect when damaged. Ported from Xonotic code X-Git-Url: https://de.git.xonotic.org/?p=voretournament%2Fvoretournament.git;a=commitdiff_plain;h=d1017baa8f49f15222934e69cc92939eedabfc8b Blur postprocessing effect when damaged. Ported from Xonotic code --- diff --git a/data/defaultVoretournament.cfg b/data/defaultVoretournament.cfg index f1202cc4..b13d32c1 100644 --- a/data/defaultVoretournament.cfg +++ b/data/defaultVoretournament.cfg @@ -578,6 +578,7 @@ set g_bloodloss 0 "amount of health below which blood loss occurs" set g_footsteps 1 "serverside footstep sounds" // effects +r_glsl_postprocess 1 r_picmipsprites 0 // Voretournament uses sprites that should never be picmipped (team mate, typing, waypoints) r_mipsprites 1 r_mipskins 1 @@ -1060,6 +1061,8 @@ con_notifysize 10 con_notifyalign 0 seta hud_damage 0.55 "an improved version of gl_polyblend for damage, draw an image instead when hurt" +seta hud_damage_blur 10 "Use postprocessing to blur the screen when you have taken damage. This can be paired with current hud damage or just used alone. Higher values = more blur" +seta hud_damage_blur_alpha 0.5 "Amount of alpha to use when merging the blurred layers back into the render. Turning this up higher will remove bloom, so it's best to find a balance" seta hud_damage_gentle_alpha_multiplier 0.10 "how much to multiply alpha of flash when using the cl_gentle version, it's much more opaque than the non-gentle version" seta hud_damage_gentle_color "1 0.7 1" "color of flash for cl_gentle version" seta hud_damage_color "1 0 0" "color of flash" @@ -1072,6 +1075,10 @@ seta hud_damage_pain_threshold_lower_health 50 "at which health we start lowerin seta hud_damage_pain_threshold_pulsating_min 0.6 "minimum value when calculating the pulse: max(pulsating_min, fabs(sin(PI * time / period))" seta hud_damage_pain_threshold_pulsating_period 0.8 "one pulse every X seconds" +seta hud_postprocessing 1 "enables the ability for effects such as hud_damage_blur and hud_contents to apply a postprocessing method upon the screen - enabling this disables manual editing of the postprocess cvars" +seta hud_postprocessing_maxbluralpha 0.5 "maximum alpha which the blur postprocess can be" +seta hud_postprocessing_maxblurradius 10 "maximum radius which the blur postprocess can be" + seta hud_contents 1 "an improved version of gl_polyblend for liquids such as water/lava/slime, draw a filler when inside the liquid" seta hud_contents_factor 1 "factor at which to multiply the current faded value." seta hud_contents_fadeintime 0.02 "factor of time it takes for the alpha level to reach normal value when entering the liquid" diff --git a/data/qcsrc/client/View.qc b/data/qcsrc/client/View.qc index 07321ed6..42fdf05c 100644 --- a/data/qcsrc/client/View.qc +++ b/data/qcsrc/client/View.qc @@ -257,6 +257,7 @@ float myhealth, myhealth_prev, myhealth_flash; float contentavgalpha, liquidalpha_prev; vector myhealth_gentlergb; vector liquidcolor_prev; +vector damage_blurpostprocess, content_blurpostprocess; string artwork_image; string intermission_song; string NextFrameCommand; @@ -562,6 +563,38 @@ void CSQC_UpdateView(float w, float h) } else drawpic('0 0 0', "gfx/blood", '1 0 0' * vid_conwidth + '0 1 0' * vid_conheight, stov(cvar_string("hud_damage_color")), bound(0, myhealth_flash_temp, 1) * cvar("hud_damage"), DRAWFLAG_NORMAL); + + if(cvar("hud_postprocessing")) + { + if(cvar("hud_damage_blur")) + { + damage_blurpostprocess_x = 1; + damage_blurpostprocess_y = bound(0, myhealth_flash_temp, 1) * cvar("hud_damage_blur"); + damage_blurpostprocess_z = bound(0, myhealth_flash_temp, 1) * cvar("hud_damage_blur_alpha"); + } + else + { + damage_blurpostprocess_x = 0; + damage_blurpostprocess_y = 0; + damage_blurpostprocess_z = 0; + } + } + } + + if(cvar("hud_postprocessing")) + { // lets apply the postprocess effects from the previous two functions if needed + if(damage_blurpostprocess_x || content_blurpostprocess_x) + { + float blurradius = bound(0, damage_blurpostprocess_y + content_blurpostprocess_y, cvar("hud_postprocessing_maxblurradius")); + float bluralpha = bound(0, damage_blurpostprocess_z + content_blurpostprocess_z, cvar("hud_postprocessing_maxbluralpha")); + cvar_set("r_glsl_postprocess_uservec1", strcat(ftos(blurradius), " ", ftos(bluralpha), " 0 0")); + cvar_set("r_glsl_postprocess_uservec1_enable", "1"); + } + else + { + cvar_set("r_glsl_postprocess_uservec1", "0 0 0 0"); + cvar_set("r_glsl_postprocess_uservec1_enable", "0"); + } } // Draw the mouse cursor