5 static const int COLORIZE_NV = 100;
8 static const float COLOR_SHOCK = 0.1;
13 static int m_BlurInventory;
14 static int m_BlurDrunk;
15 static int m_BlurFever;
16 static int m_BlurMenu;
17 static int m_BlurOptics;
18 static int m_BlurFlashbang;
19 static int m_BlurShock;
21 static int m_BurlapBlindness;
22 static int m_DyingEffect;
23 static int m_ShockEffect;
25 static int m_ChromAbbOptic;
28 static int m_VignetteUnconscious;
29 static int m_VignetteShock;
30 static int m_VignetteTunnel;
31 static int m_VignetteMenu;
33 static float m_BloodSaturation;
46 static float m_ColorValueTotal[4] = {0,0,0,0};
47 static float m_ColorOverlayTotal;
59 if ( m_ChromAbbValues )
61 delete m_ChromAbbValues;
63 if ( m_VignetteEffects )
65 delete m_VignetteEffects;
67 if ( m_VignetteValues )
69 delete m_VignetteValues;
76 m_MatColors =
GetGame().GetWorld().GetMaterial(
"graphics/materials/postprocess/glow");
77 m_RadialBlur =
GetGame().GetWorld().GetMaterial(
"graphics/materials/postprocess/radialblur");
84 m_BlurInventory = RegisterBlurEffect();
85 m_BlurDrunk = RegisterBlurEffect();
86 m_BlurFever = RegisterBlurEffect();
87 m_BlurMenu = RegisterBlurEffect();
88 m_BlurOptics = RegisterBlurEffect();
89 m_BlurFlashbang = RegisterBlurEffect();
92 m_ChromAbbOptic = RegisterChromAbbEffect();
96 m_VignetteUnconscious = RegisterVignetteEffect();
97 m_VignetteShock = RegisterVignetteEffect();
98 m_VignetteTunnel = RegisterVignetteEffect();
99 m_VignetteMenu = RegisterVignetteEffect();
105 m_BurlapBlindness = RegisterColorEffect();
106 m_DyingEffect = RegisterColorEffect();
107 m_ShockEffect = RegisterColorEffect();
115 m_ColorizeEffects.Set(
PPEffects.COLORIZE_NV, colorizeDefault);
120 static void ResetBlurEffects()
124 for (
int i = 0; i < m_BlurValues.Count(); ++i )
132 static void ResetRadialBlur()
134 SetRadialBlur(0,0,0,0);
137 static void SetBlurValue(
int index,
float value)
139 if ( m_BlurValues && index < m_BlurValues.Count() )
141 m_BlurValues[index] = value;
145 Print(
"Error: PPEffects: m_BlurValues with index: "+ index +
" is not registered.");
149 static int RegisterBlurEffect()
151 return m_BlurValues.Insert(0);
156 static void SetRadialBlur(
float powerX,
float powerY,
float offsetX,
float offsetY )
160 m_RadialBlur.SetParam(
"PowerX", powerX);
161 m_RadialBlur.SetParam(
"PowerY", powerY);
162 m_RadialBlur.SetParam(
"OffsetX", offsetX);
163 m_RadialBlur.SetParam(
"OffsetY", offsetY);
168 static void SetBlur(
float value)
172 Material mat_blur =
GetGame().GetWorld().GetMaterial(
"graphics/materials/postprocess/gauss");
176 mat_blur.SetParam(
"Intensity", value);
182 static void UpdateBlur()
184 float blur_value_total = 0;
187 for (
int i = 0; i < m_BlurValues.Count(); ++i )
189 blur_value_total += m_BlurValues[i];
193 SetBlur( blur_value_total );
197 static void SetBlurInventory(
float value)
199 SetBlurValue(m_BlurInventory, value);
204 static void SetBlurDrunk(
float value)
206 SetBlurValue(m_BlurDrunk, value);
212 static void SetBlurFever(
float value)
214 SetBlurValue(m_BlurFever, value);
220 static void SetBlurMenu(
float value)
222 SetBlurValue(m_BlurMenu, value);
228 static void SetBlurOptics(
float value)
230 SetBlurValue(m_BlurOptics, value);
236 static void SetBlurFlashbang(
float value)
238 SetBlurValue(m_BlurFlashbang, value);
242 static void SetBlurShock(
float value)
244 SetBlurValue(m_BlurShock, value);
255 static int RegisterChromAbbEffect()
257 return m_ChromAbbValues.Insert(0);
260 static void ResetChromAbbEffects()
262 if( m_ChromAbbValues )
264 for (
int i = 0; i < m_ChromAbbValues.Count(); ++i )
266 m_ChromAbbValues[i] = 0;
272 static void SetChromAbbValue(
int index,
float value)
274 if ( m_ChromAbbValues && index < m_ChromAbbValues.Count() )
276 m_ChromAbbValues[index] = value;
280 Print(
"Error: PPEffects: m_ChromAbbValues with index: "+ index +
" is not registered.");
284 static void SetChromAbb(
float value)
291 m_MatColors.SetParam(
"MaxChromAbberation", value);
298 static void UpdateChromAbb()
300 float chromabb_value_total = 0;
301 if( m_ChromAbbValues )
303 for (
int i = 0; i < m_ChromAbbValues.Count(); ++i )
305 chromabb_value_total += m_ChromAbbValues[i];
309 SetChromAbb( chromabb_value_total );
312 static void SetChromAbbOptic(
float value)
314 SetChromAbbValue(m_ChromAbbOptic, value);
343 static void ResetColorEffects()
347 for (
int i = 0; i < m_ColorEffect.Count(); ++i )
350 m_ColorValues.Set(i,{0,0,0,0,0});
356 static void SetColorValue(
int index,
float r,
float g,
float b,
float a,
float overlay)
358 if ( index < m_ColorEffect.Count() )
362 m_ColorValues.Set(index, values);
366 Print(
"Error: PPEffects: m_ColorValues with index: "+ index +
" is not registered.");
370 static int RegisterColorEffect()
372 return m_ColorEffect.Insert(0);
375 static void UpdateColor()
377 float color_value_total[4] = {0,0,0,0};
388 for (
int i = 0; i < m_ColorValues.Count(); ++i )
390 int key = m_ColorValues.GetKey(i);
393 color_value_total[0] = color_value_total[0] + value[0];
394 color_value_total[1] = color_value_total[1] + value[1];
395 color_value_total[2] = color_value_total[2] + value[2];
396 color_value_total[3] = color_value_total[3] + value[3];
397 color_overlay += value[4];
400 m_ColorValueTotal = color_value_total;
401 m_ColorOverlayTotal = color_overlay;
402 m_MatColors.SetParam(
"OverlayColor", color_value_total);
403 m_MatColors.SetParam(
"OverlayFactor", color_overlay);
413 static void SetLensEffect(
float lens,
float chromAbb,
float centerX,
float centerY)
415 PerformSetLensEffect(lens, chromAbb, centerX, centerY);
419 static void PerformSetLensEffect(
float lens,
float chromAbb,
float centerX,
float centerY)
421 m_MatColors.SetParam(
"LensDistort", lens);
422 SetChromAbbOptic(chromAbb);
423 m_MatColors.SetParam(
"LensCenterX", centerX);
424 m_MatColors.SetParam(
"LensCenterY", centerY);
434 static void SetVignette(
float intensity,
float R,
float G,
float B,
float A)
442 m_MatColors.SetParam(
"Vignette", intensity);
443 m_MatColors.SetParam(
"VignetteColor", color);
446 static void SetVignetteEffectValue(
int index,
float intensity,
float r,
float g,
float b,
float a)
448 if ( index < m_VignetteEffects.Count() )
452 m_VignetteValues.Set(index, values);
456 Print(
"Error: PPEffects: m_ColorValues with index: "+ index +
" is not registered.");
460 static int RegisterVignetteEffect()
462 return m_VignetteEffects.Insert(0);
465 static void SetUnconsciousnessVignette(
float value)
467 SetVignetteEffectValue(m_VignetteUnconscious, value, 0,0,0,0);
471 static void SetShockVignette(
float value)
473 SetVignetteEffectValue(m_VignetteShock, value, 0,0,0,0);
477 static void SetTunnelVignette(
float value)
479 SetVignetteEffectValue(m_VignetteTunnel, value, 0,0,0,0);
483 static void SetMenuVignette(
float value)
485 SetVignetteEffectValue(m_VignetteMenu, value, 0,0,0,0);
489 static void ResetVignettes()
491 if( m_VignetteValues )
493 for (
int i = 0; i < m_VignetteValues.Count(); ++i )
497 m_VignetteValues.Set(i, values);
503 static void OverrideDOF(
bool enable,
float focusDistance,
float focusLength,
float focusLengthNear,
float blur,
float focusDepthOffset)
505 GetGame().OverrideDOF(enable, focusDistance, focusLength, focusLengthNear, blur, focusDepthOffset);
508 static void AddPPMask(
float ndcX,
float ndcY,
float ndcRadius,
float ndcBlur)
510 GetGame().AddPPMask(ndcX, ndcY, ndcRadius, ndcBlur);
513 static void ResetPPMask()
518 static void ResetDOFOverride()
520 OverrideDOF(
false,0,0,0,0,1);
523 static void ResetLensEffect()
525 SetLensEffect(0,0,0,0);
528 static void HitEffect(
float value)
530 float m_HitEffectColor[4];
531 m_HitEffectColor[0] =
Math.Lerp(
Math.Clamp(m_ColorValueTotal[0],0,1), 1, value);
532 m_HitEffectColor[1] = 0;
533 m_HitEffectColor[2] = 0;
534 m_HitEffectColor[3] =
Math.Lerp(
Math.Clamp(m_ColorValueTotal[0],0,1), 1, value);
545 m_MatColors.SetParam(
"OverlayColor", m_HitEffectColor);
546 m_MatColors.SetParam(
"OverlayFactor", 0.05);
549 static void SetShockEffectColor(
float value)
552 SetColorValue(m_ShockEffect, COLOR_SHOCK, COLOR_SHOCK, COLOR_SHOCK, 1, value);
554 SetColorValue(m_ShockEffect, 0, 0, 0, 1, value);
560 float hitEffectColor[4];
561 hitEffectColor[0] = 1;
562 hitEffectColor[1] = 1;
563 hitEffectColor[2] = 1;
564 hitEffectColor[3] =
Math.Lerp(
Math.Clamp(m_ColorValueTotal[0],0,1), 1, value);
566 m_MatColors.SetParam(
"OverlayColor", hitEffectColor);
567 m_MatColors.SetParam(
"OverlayFactor", 0.75);
570 static void EnableBurlapSackBlindness()
572 SetColorValue(m_BurlapBlindness, 0, 0, 0, 1, 1.0);
577 static void DisableBurlapSackBlindness()
579 SetColorValue(m_BurlapBlindness, 0, 0, 0, 0, 0.0);
584 static void SetDeathDarkening(
float value)
586 value =
Math.Clamp(value,0,1);
587 SetColorValue(m_DyingEffect, 0, 0, 0, 1, value);
595 static void UpdateSaturation()
597 m_MatColors.SetParam(
"Saturation", m_BloodSaturation);
600 static void UpdateVignette()
605 float intensity_value_total = 0;
606 if( m_VignetteEffects )
608 for (
int i = 0; i < m_VignetteEffects.Count(); ++i )
610 if (m_VignetteValues.Get(i))
616 color[0] = m_VignetteValues.Get(i).Get(1);
617 color[1] = m_VignetteValues.Get(i).Get(2);
618 color[2] = m_VignetteValues.Get(i).Get(3);
619 color[3] = m_VignetteValues.Get(i).Get(4);
621 intesity = m_VignetteValues.Get(i).Get(0);
622 intensity_value_total += intesity;
637 SetVignette( intensity_value_total, color[0], color[1], color[2], color[3] );
640 static void SetBloodSaturation(
float value)
642 m_BloodSaturation = value;
659 static void SetColorizationNV(
float r,
float g,
float b)
662 m_ColorizeEffects.Set(
PPEffects.COLORIZE_NV, colorizeArray);
666 static void UpdateColorize()
668 bool foundActiveEffect =
false;
669 int lowestKey = 1000000;
672 for (
int i = 0; i < m_ColorizeEffects.Count(); i++)
674 int currentKey = m_ColorizeEffects.GetKey(i);
675 array<float> colorizeValues = m_ColorizeEffects.Get(currentKey);
677 for (
int j = 0; j < colorizeValues.Count(); j++)
679 if (colorizeValues[j] != 0.0)
681 if (currentKey < lowestKey)
683 chosenArray = colorizeValues;
684 lowestKey = currentKey;
685 foundActiveEffect =
true;
691 if (foundActiveEffect)
694 color[0] = chosenArray[0];
695 color[1] = chosenArray[1];
696 color[2] = chosenArray[2];
698 m_MatColors.SetParam(
"ColorizationColor", color);
706 static void ResetColorize()
713 m_MatColors.SetParam(
"ColorizationColor", color);
717 static void SetEVValuePP(
float value)
724 static void SetNVParams(
float light_mult,
float noise_intensity,
float sharpness,
float grain_size)
726 Material matHDR =
GetGame().GetWorld().GetMaterial(
"Graphics/Materials/postprocess/filmgrainNV");
731 g_Game.NightVissionLightParams(light_mult, noise_intensity);
732 matHDR.SetParam(
"Sharpness", sharpness);
733 matHDR.SetParam(
"GrainSize", grain_size);
737 static void SetBloom(
float thres,
float steep,
float inten)
739 m_MatColors.SetParam(
"BloomThreshold", thres);
740 m_MatColors.SetParam(
"BloomSteepness", steep);
741 m_MatColors.SetParam(
"BloomIntensity", inten);
744 static void ResetAll()
752 SetBloodSaturation(1);