ppeffects.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756
  1. //! Deprecated; 'PPEManager' used instead
  2. class PPEffects
  3. {
  4. // COLORIZE IDs
  5. static const int COLORIZE_NV = 100;
  6. //CONSTANTS
  7. static const float COLOR_SHOCK = 0.1;//shock color value (relative) //todo
  8. //-------------------------------------------------------
  9. // BLUR START
  10. //-------------------------------------------------------
  11. static int m_BlurInventory;
  12. static int m_BlurDrunk;
  13. static int m_BlurFever;
  14. static int m_BlurMenu;
  15. static int m_BlurOptics;
  16. static int m_BlurFlashbang;
  17. static int m_BlurShock;
  18. static int m_BurlapBlindness;
  19. static int m_DyingEffect;
  20. static int m_ShockEffect;
  21. static int m_ChromAbbOptic;
  22. //static int m_ChromAbbShock;
  23. static int m_VignetteUnconscious;
  24. static int m_VignetteShock;
  25. static int m_VignetteTunnel;
  26. static int m_VignetteMenu;
  27. static float m_BloodSaturation;
  28. static ref array<float> m_BlurValues;
  29. static ref array<float> m_ChromAbbValues;
  30. static ref array<int> m_VignetteEffects;
  31. static ref map<int, ref array<float>> m_VignetteValues;
  32. static ref map<int, ref array<float>> m_ColorValues;
  33. static ref array<float> m_ColorEffect;
  34. static ref map<int, ref array<float>> m_ColorizeEffects;
  35. //static float m_UnconsciousVignetteColor[4];
  36. //static float m_UnconsciousVignetteIntesity;
  37. static float m_ColorValueTotal[4] = {0,0,0,0};
  38. static float m_ColorOverlayTotal;
  39. static Material m_MatColors;
  40. static Material m_RadialBlur;
  41. static void Init()
  42. {
  43. //Print("---Init PPEffects---");
  44. if ( m_BlurValues )
  45. {
  46. delete m_BlurValues;
  47. }
  48. if ( m_ChromAbbValues )
  49. {
  50. delete m_ChromAbbValues;
  51. }
  52. if ( m_VignetteEffects )
  53. {
  54. delete m_VignetteEffects;
  55. }
  56. if ( m_VignetteValues )
  57. {
  58. delete m_VignetteValues;
  59. }
  60. if ( m_ColorEffect )
  61. {
  62. delete m_ColorEffect;
  63. }
  64. m_MatColors = GetGame().GetWorld().GetMaterial("graphics/materials/postprocess/glow");
  65. m_RadialBlur = GetGame().GetWorld().GetMaterial("graphics/materials/postprocess/radialblur");
  66. m_BlurValues = new array<float>;
  67. m_ChromAbbValues = new array<float>;
  68. m_VignetteEffects = new array<int>;
  69. m_VignetteValues = new map<int, ref array<float>>;
  70. // add new blur effects here
  71. m_BlurInventory = RegisterBlurEffect();
  72. m_BlurDrunk = RegisterBlurEffect();
  73. m_BlurFever = RegisterBlurEffect();
  74. m_BlurMenu = RegisterBlurEffect();
  75. m_BlurOptics = RegisterBlurEffect();
  76. m_BlurFlashbang = RegisterBlurEffect();
  77. // add chromatic abberation effects here
  78. m_ChromAbbOptic = RegisterChromAbbEffect();
  79. //m_ChromAbbShock = RegisterChromAbbEffect();
  80. // add vignette effects here
  81. m_VignetteUnconscious = RegisterVignetteEffect();
  82. m_VignetteShock = RegisterVignetteEffect();
  83. m_VignetteTunnel = RegisterVignetteEffect();
  84. m_VignetteMenu = RegisterVignetteEffect();
  85. m_ColorEffect = new array<float>;
  86. m_ColorValues = new map<int, ref array<float>>;
  87. // add new color effects here
  88. m_BurlapBlindness = RegisterColorEffect();
  89. m_DyingEffect = RegisterColorEffect();
  90. m_ShockEffect = RegisterColorEffect();
  91. // ------------------------NV-related stuff below------------------------
  92. array<float> colorizeDefault = {0.0, 0.0, 0.0};
  93. m_ColorizeEffects = new map<int, ref array<float>>;
  94. // colorize: r, g, b
  95. // colorize effects registration
  96. m_ColorizeEffects.Set(PPEffects.COLORIZE_NV, colorizeDefault);
  97. //SetNVParams(1.0, 0.0, 2.35, 2.75); //default values
  98. // ------------------------End of NV-related stuff------------------------
  99. }
  100. static void ResetBlurEffects()
  101. {
  102. if( m_BlurValues )
  103. {
  104. for ( int i = 0; i < m_BlurValues.Count(); ++i )
  105. {
  106. m_BlurValues[i] = 0;
  107. }
  108. UpdateBlur();
  109. }
  110. }
  111. static void ResetRadialBlur()
  112. {
  113. SetRadialBlur(0,0,0,0);
  114. }
  115. static void SetBlurValue(int index, float value)
  116. {
  117. if ( m_BlurValues && index < m_BlurValues.Count() )
  118. {
  119. m_BlurValues[index] = value;
  120. }
  121. else
  122. {
  123. Print("Error: PPEffects: m_BlurValues with index: "+ index +" is not registered.");
  124. }
  125. }
  126. static int RegisterBlurEffect()
  127. {
  128. return m_BlurValues.Insert(0);
  129. }
  130. //-------------------------------------------------------
  131. //! sets blur effect to an absolute value between 0..1
  132. static void SetRadialBlur(float powerX, float powerY, float offsetX, float offsetY )
  133. {
  134. if (GetGame())
  135. {
  136. m_RadialBlur.SetParam("PowerX", powerX);
  137. m_RadialBlur.SetParam("PowerY", powerY);
  138. m_RadialBlur.SetParam("OffsetX", offsetX);
  139. m_RadialBlur.SetParam("OffsetY", offsetY);
  140. }
  141. }
  142. //-------------------------------------------------------
  143. //! sets blur effect to an absolute value between 0..1
  144. static void SetBlur(float value)
  145. {
  146. if (GetGame())
  147. {
  148. Material mat_blur = GetGame().GetWorld().GetMaterial("graphics/materials/postprocess/gauss");
  149. if (mat_blur)
  150. {
  151. mat_blur.SetParam("Intensity", value);
  152. }
  153. }
  154. }
  155. //-------------------------------------------------------
  156. //! updates the blur post process effect where the resulting blur is an aggregate of all individual blur effect values
  157. static void UpdateBlur()
  158. {
  159. float blur_value_total = 0;
  160. if( m_BlurValues )
  161. {
  162. for ( int i = 0; i < m_BlurValues.Count(); ++i )
  163. {
  164. blur_value_total += m_BlurValues[i];
  165. }
  166. }
  167. SetBlur( blur_value_total );
  168. }
  169. //-------------------------------------------------------
  170. //! Set blur inventory effect to a specified 'value' between 0..1
  171. static void SetBlurInventory(float value)
  172. {
  173. SetBlurValue(m_BlurInventory, value);
  174. UpdateBlur();
  175. }
  176. //-------------------------------------------------------
  177. //! Set blur drunk effect to a specified 'value' between 0..1
  178. static void SetBlurDrunk(float value)
  179. {
  180. SetBlurValue(m_BlurDrunk, value);
  181. UpdateBlur();
  182. }
  183. //-------------------------------------------------------
  184. //! Set blur drunk effect to a specified 'value' between 0..1
  185. static void SetBlurFever(float value)
  186. {
  187. SetBlurValue(m_BlurFever, value);
  188. UpdateBlur();
  189. }
  190. //-------------------------------------------------------
  191. //! Set menu blur to a specified 'value' between 0..1
  192. static void SetBlurMenu(float value)
  193. {
  194. SetBlurValue(m_BlurMenu, value);
  195. UpdateBlur();
  196. }
  197. //-------------------------------------------------------
  198. //! Set optics and ironsights blur to a specified 'value' between 0..1
  199. static void SetBlurOptics(float value)
  200. {
  201. SetBlurValue(m_BlurOptics, value);
  202. UpdateBlur();
  203. }
  204. //-------------------------------------------------------
  205. //! Set blur flashbang hit effect to a specified 'value' between 0..1
  206. static void SetBlurFlashbang(float value)
  207. {
  208. SetBlurValue(m_BlurFlashbang, value);
  209. UpdateBlur();
  210. }
  211. static void SetBlurShock(float value)
  212. {
  213. SetBlurValue(m_BlurShock, value);
  214. UpdateBlur();
  215. }
  216. //-------------------------------------------------------
  217. // BLUR END
  218. //-------------------------------------------------------
  219. //-------------------------------------------------------
  220. // CHROMATIC ABBERATION
  221. //-------------------------------------------------------
  222. static int RegisterChromAbbEffect()
  223. {
  224. return m_ChromAbbValues.Insert(0);
  225. }
  226. static void ResetChromAbbEffects()
  227. {
  228. if( m_ChromAbbValues )
  229. {
  230. for ( int i = 0; i < m_ChromAbbValues.Count(); ++i )
  231. {
  232. m_ChromAbbValues[i] = 0;
  233. }
  234. UpdateChromAbb();
  235. }
  236. }
  237. static void SetChromAbbValue(int index, float value)
  238. {
  239. if ( m_ChromAbbValues && index < m_ChromAbbValues.Count() )
  240. {
  241. m_ChromAbbValues[index] = value;
  242. }
  243. else
  244. {
  245. Print("Error: PPEffects: m_ChromAbbValues with index: "+ index +" is not registered.");
  246. }
  247. }
  248. static void SetChromAbb(float value)
  249. {
  250. if (GetGame())
  251. {
  252. if (m_MatColors)
  253. {
  254. //Print("SetChromAbb: " + value);
  255. m_MatColors.SetParam("MaxChromAbberation", value);
  256. //SetVignette(value,0,255,0);
  257. }
  258. }
  259. }
  260. //-------------------------------------------------------
  261. //! updates the chromatic abberation post process effect where the resulting chromabb is an aggregate of all individual chromabb effect values
  262. static void UpdateChromAbb()
  263. {
  264. float chromabb_value_total = 0;
  265. if( m_ChromAbbValues )
  266. {
  267. for ( int i = 0; i < m_ChromAbbValues.Count(); ++i )
  268. {
  269. chromabb_value_total += m_ChromAbbValues[i]; //currently additive!
  270. }
  271. }
  272. SetChromAbb( chromabb_value_total );
  273. }
  274. static void SetChromAbbOptic(float value)
  275. {
  276. SetChromAbbValue(m_ChromAbbOptic, value);
  277. UpdateChromAbb();
  278. }
  279. /*static void SetChromAbbShock(float value)
  280. {
  281. SetChromAbbValue(m_ChromAbbShock, value);
  282. UpdateChromAbb();
  283. }*/
  284. //-------------------------------------------------------
  285. // CHROMATIC ABBERATION END
  286. //-------------------------------------------------------
  287. /*
  288. static void SetOverlayColor(float r, float g, float b, float a)
  289. {
  290. Material matColors = GetGame().GetWorld().GetMaterial("graphics/materials/postprocess/glow");
  291. m_Color[0] = r;
  292. m_Color[1] = g;
  293. m_Color[2] = b;
  294. m_Color[3] = a;
  295. matColors.SetParam("OverlayColor", m_Color);
  296. matColors.SetParam("OverlayFactor", a);
  297. }*/
  298. static void ResetColorEffects()
  299. {
  300. if( m_ColorEffect )
  301. {
  302. for ( int i = 0; i < m_ColorEffect.Count(); ++i )
  303. {
  304. //m_ColorEffect[i] = 0;
  305. m_ColorValues.Set(i,{0,0,0,0,0});
  306. }
  307. UpdateColor();
  308. }
  309. }
  310. static void SetColorValue(int index, float r, float g, float b, float a, float overlay)
  311. {
  312. if ( index < m_ColorEffect.Count() )
  313. {
  314. array<float> values = {r,g,b,a,overlay};
  315. m_ColorValues.Set(index, values);
  316. }
  317. else
  318. {
  319. Print("Error: PPEffects: m_ColorValues with index: "+ index +" is not registered.");
  320. }
  321. }
  322. static int RegisterColorEffect()
  323. {
  324. return m_ColorEffect.Insert(0);
  325. }
  326. static void UpdateColor()
  327. {
  328. float color_value_total[4] = {0,0,0,0};
  329. float color_overlay;
  330. /*
  331. m_MatColors.ResetParam("OverlayColor");
  332. m_MatColors.ResetParam("OverlayFactor");
  333. */
  334. if( !GetGame() || !GetGame().GetWorld() )
  335. {
  336. return;
  337. }
  338. for ( int i = 0; i < m_ColorValues.Count(); ++i )
  339. {
  340. int key = m_ColorValues.GetKey(i);
  341. array<float> value = m_ColorValues.Get(key);
  342. color_value_total[0] = color_value_total[0] + value[0];
  343. color_value_total[1] = color_value_total[1] + value[1];
  344. color_value_total[2] = color_value_total[2] + value[2];
  345. color_value_total[3] = color_value_total[3] + value[3];
  346. color_overlay += value[4];
  347. }
  348. m_ColorValueTotal = color_value_total;
  349. m_ColorOverlayTotal = color_overlay;
  350. m_MatColors.SetParam("OverlayColor", color_value_total);
  351. m_MatColors.SetParam("OverlayFactor", color_overlay);
  352. }
  353. /*!
  354. set lens effect
  355. \param lens <-5, 5>, 0 = disable (performance plus), > 0 = outside effect, < 0 inside effect
  356. \param chromAbb <0, 1>, chromaticity, 1 = max, 0 disable (performance plus)
  357. \param centerX <-1, 1>, center of effect, 0 = screen center in X
  358. \param centerY <-1, 1>, center of effect, 0 = screen center in Y
  359. */
  360. static void SetLensEffect(float lens, float chromAbb, float centerX, float centerY)
  361. {
  362. PerformSetLensEffect(lens, chromAbb, centerX, centerY);
  363. }
  364. //!added for convenience
  365. static void PerformSetLensEffect(float lens, float chromAbb, float centerX, float centerY)
  366. {
  367. m_MatColors.SetParam("LensDistort", lens);
  368. SetChromAbbOptic(chromAbb);
  369. m_MatColors.SetParam("LensCenterX", centerX);
  370. m_MatColors.SetParam("LensCenterY", centerY);
  371. }
  372. /*!
  373. set vignette
  374. \param intensity <0, 1>, intensity of effect, 0 = disable
  375. \param R
  376. \param G
  377. \param B
  378. */
  379. static void SetVignette(float intensity, float R, float G, float B, float A)
  380. {
  381. float color[4];
  382. color[0] = R;
  383. color[1] = G;
  384. color[2] = B;
  385. color[3] = A;
  386. m_MatColors.SetParam("Vignette", intensity);
  387. m_MatColors.SetParam("VignetteColor", color);
  388. }
  389. static void SetVignetteEffectValue(int index, float intensity, float r, float g, float b, float a)
  390. {
  391. if ( index < m_VignetteEffects.Count() )
  392. {
  393. array<float> values = {intensity,r,g,b,a};
  394. m_VignetteValues.Set(index, values);
  395. }
  396. else
  397. {
  398. Print("Error: PPEffects: m_ColorValues with index: "+ index +" is not registered.");
  399. }
  400. }
  401. static int RegisterVignetteEffect()
  402. {
  403. return m_VignetteEffects.Insert(0);
  404. }
  405. static void SetUnconsciousnessVignette(float value)
  406. {
  407. SetVignetteEffectValue(m_VignetteUnconscious, value, 0,0,0,0); //todo
  408. UpdateVignette();
  409. }
  410. static void SetShockVignette(float value)
  411. {
  412. SetVignetteEffectValue(m_VignetteShock, value, 0,0,0,0); //todo
  413. UpdateVignette();
  414. }
  415. static void SetTunnelVignette(float value)
  416. {
  417. SetVignetteEffectValue(m_VignetteTunnel, value, 0,0,0,0); //todo
  418. UpdateVignette();
  419. }
  420. static void SetMenuVignette(float value)
  421. {
  422. SetVignetteEffectValue(m_VignetteMenu, value, 0,0,0,0); //todo
  423. UpdateVignette();
  424. }
  425. static void ResetVignettes()
  426. {
  427. if( m_VignetteValues )
  428. {
  429. for ( int i = 0; i < m_VignetteValues.Count(); ++i )
  430. {
  431. array<float> values = {0,0,0,0,0};
  432. m_VignetteValues.Set(i, values);
  433. }
  434. UpdateVignette();
  435. }
  436. }
  437. static void OverrideDOF(bool enable, float focusDistance, float focusLength, float focusLengthNear, float blur, float focusDepthOffset)
  438. {
  439. GetGame().OverrideDOF(enable, focusDistance, focusLength, focusLengthNear, blur, focusDepthOffset);
  440. }
  441. static void AddPPMask(float ndcX, float ndcY, float ndcRadius, float ndcBlur)
  442. {
  443. GetGame().AddPPMask(ndcX, ndcY, ndcRadius, ndcBlur);
  444. }
  445. static void ResetPPMask()
  446. {
  447. if( GetGame() ) GetGame().ResetPPMask();
  448. }
  449. static void ResetDOFOverride()
  450. {
  451. OverrideDOF(false,0,0,0,0,1);
  452. }
  453. static void ResetLensEffect()
  454. {
  455. SetLensEffect(0,0,0,0);
  456. }
  457. static void HitEffect(float value)
  458. {
  459. float m_HitEffectColor[4];
  460. m_HitEffectColor[0] = Math.Lerp(Math.Clamp(m_ColorValueTotal[0],0,1), 1, value);
  461. m_HitEffectColor[1] = 0;
  462. m_HitEffectColor[2] = 0;
  463. m_HitEffectColor[3] = Math.Lerp(Math.Clamp(m_ColorValueTotal[0],0,1), 1, value);
  464. /*
  465. Print("---------------------------");
  466. Print("m_ColorValueTotal[0]: " + m_ColorValueTotal[0]);
  467. Print("value: " + value);
  468. Print("---------------------------");
  469. Print("r: " + m_HitEffectColor[0]);
  470. Print("g: " + m_HitEffectColor[1]);
  471. Print("b: " + m_HitEffectColor[2]);
  472. Print("a: " + m_HitEffectColor[3]);
  473. */
  474. m_MatColors.SetParam("OverlayColor", m_HitEffectColor);
  475. m_MatColors.SetParam("OverlayFactor", 0.05);
  476. }
  477. static void SetShockEffectColor(float value)
  478. {
  479. if (value > 0)
  480. SetColorValue(m_ShockEffect, COLOR_SHOCK, COLOR_SHOCK, COLOR_SHOCK, 1, value);
  481. else
  482. SetColorValue(m_ShockEffect, 0, 0, 0, 1, value);
  483. UpdateColor();
  484. }
  485. static void FlashbangEffect(float value)
  486. {
  487. float hitEffectColor[4];
  488. hitEffectColor[0] = 1;
  489. hitEffectColor[1] = 1;
  490. hitEffectColor[2] = 1;
  491. hitEffectColor[3] = Math.Lerp(Math.Clamp(m_ColorValueTotal[0],0,1), 1, value);
  492. m_MatColors.SetParam("OverlayColor", hitEffectColor);
  493. m_MatColors.SetParam("OverlayFactor", 0.75);
  494. }
  495. static void EnableBurlapSackBlindness()
  496. {
  497. SetColorValue(m_BurlapBlindness, 0, 0, 0, 1, 1.0);
  498. UpdateColor();
  499. g_Game.SetEVValue(-5);
  500. }
  501. static void DisableBurlapSackBlindness()
  502. {
  503. SetColorValue(m_BurlapBlindness, 0, 0, 0, 0, 0.0);
  504. UpdateColor();
  505. g_Game.SetEVValue(0);
  506. }
  507. static void SetDeathDarkening(float value)
  508. {
  509. value = Math.Clamp(value,0,1);
  510. SetColorValue(m_DyingEffect, 0, 0, 0, 1, value);
  511. UpdateColor();
  512. if (value > 0.99)
  513. SetEVValuePP(-5); //additional "darkness" to avoid lens flare
  514. else
  515. SetEVValuePP(0);
  516. }
  517. static void UpdateSaturation()
  518. {
  519. m_MatColors.SetParam("Saturation", m_BloodSaturation/*+add_additional_modifiers_here*/);
  520. }
  521. static void UpdateVignette()
  522. {
  523. float color[4];
  524. float intesity;
  525. float intensity_value_total = 0; //use just the highest?
  526. if( m_VignetteEffects )
  527. {
  528. for ( int i = 0; i < m_VignetteEffects.Count(); ++i )
  529. {
  530. if (m_VignetteValues.Get(i))
  531. {
  532. /*color[0] = m_VignetteValues.Get(i)[1]; //red
  533. color[1] = m_VignetteValues.Get(i)[2]; //green
  534. color[2] = m_VignetteValues.Get(i)[3]; //blue
  535. color[3] = m_VignetteValues.Get(i)[4]; //alpha*/
  536. color[0] = m_VignetteValues.Get(i).Get(1); //red
  537. color[1] = m_VignetteValues.Get(i).Get(2); //green
  538. color[2] = m_VignetteValues.Get(i).Get(3); //blue
  539. color[3] = m_VignetteValues.Get(i).Get(4); //alpha
  540. intesity = m_VignetteValues.Get(i).Get(0);
  541. intensity_value_total += intesity;
  542. }
  543. else
  544. {
  545. //Print("no m_VignetteValues");
  546. }
  547. }
  548. }
  549. /*color[0] = m_UnconsciousVignetteColor[0];
  550. color[1] = m_UnconsciousVignetteColor[1];
  551. color[2] = m_UnconsciousVignetteColor[2];
  552. intesity = m_UnconsciousVignetteIntesity;*/
  553. SetVignette( intensity_value_total, color[0], color[1], color[2], color[3] );
  554. }
  555. static void SetBloodSaturation(float value)
  556. {
  557. m_BloodSaturation = value;
  558. UpdateSaturation();
  559. }
  560. /*static void SetUnconsciousnessVignette(float value)
  561. {
  562. m_UnconsciousVignetteIntesity = value;
  563. UpdateVignette();
  564. }
  565. static void RemoveUnconsciousnessVignette()
  566. {
  567. m_UnconsciousVignetteIntesity = 0;
  568. UpdateVignette();
  569. }*/
  570. // appropriate parts of the code will call these functions
  571. static void SetColorizationNV(float r, float g, float b)
  572. {
  573. array<float> colorizeArray = {r, g, b};
  574. m_ColorizeEffects.Set(PPEffects.COLORIZE_NV, colorizeArray);
  575. UpdateColorize();
  576. }
  577. static void UpdateColorize()
  578. {
  579. bool foundActiveEffect = false;
  580. int lowestKey = 1000000;
  581. array<float> chosenArray;
  582. // search for active effect with highest priority (lower value of key better)
  583. for (int i = 0; i < m_ColorizeEffects.Count(); i++)
  584. {
  585. int currentKey = m_ColorizeEffects.GetKey(i);
  586. array<float> colorizeValues = m_ColorizeEffects.Get(currentKey);
  587. // check for non-zero active effect
  588. for (int j = 0; j < colorizeValues.Count(); j++)
  589. {
  590. if (colorizeValues[j] != 0.0)
  591. {
  592. if (currentKey < lowestKey)
  593. {
  594. chosenArray = colorizeValues;
  595. lowestKey = currentKey;
  596. foundActiveEffect = true;
  597. break;
  598. }
  599. }
  600. }
  601. }
  602. if (foundActiveEffect)
  603. {
  604. float color[4];
  605. color[0] = chosenArray[0];
  606. color[1] = chosenArray[1];
  607. color[2] = chosenArray[2];
  608. color[3] = 0;
  609. m_MatColors.SetParam("ColorizationColor", color);
  610. }
  611. else
  612. {
  613. // no active event found, reset colorize effect
  614. ResetColorize();
  615. }
  616. }
  617. static void ResetColorize()
  618. {
  619. float color[4];
  620. color[0] = 1.0;
  621. color[1] = 1.0;
  622. color[2] = 1.0;
  623. color[3] = 0;
  624. m_MatColors.SetParam("ColorizationColor", color);
  625. }
  626. // EV check for NV optics
  627. static void SetEVValuePP(float value)
  628. {
  629. g_Game.SetEVValue(value);
  630. }
  631. // light multiplier and noise intensity (using filmgrainNV.emat!) for nvg
  632. // added other parameters for filmgrainNV.emat, sharpness and grain size
  633. static void SetNVParams(float light_mult, float noise_intensity, float sharpness, float grain_size)
  634. {
  635. Material matHDR = GetGame().GetWorld().GetMaterial("Graphics/Materials/postprocess/filmgrainNV");
  636. /*#ifdef PLATFORM_CONSOLE
  637. //worst-case scenario console fix!
  638. noise_intensity = 0.0;
  639. #endif*/
  640. g_Game.NightVissionLightParams(light_mult, noise_intensity);
  641. matHDR.SetParam("Sharpness", sharpness);
  642. matHDR.SetParam("GrainSize", grain_size);
  643. }
  644. // bloom PP, experimental stuff
  645. static void SetBloom(float thres, float steep, float inten)
  646. {
  647. m_MatColors.SetParam("BloomThreshold", thres);
  648. m_MatColors.SetParam("BloomSteepness", steep);
  649. m_MatColors.SetParam("BloomIntensity", inten);
  650. }
  651. static void ResetAll()
  652. {
  653. ResetBlurEffects();
  654. ResetColorEffects();
  655. ResetVignettes();
  656. ResetPPMask();
  657. ResetDOFOverride();
  658. ResetLensEffect();
  659. SetBloodSaturation(1);
  660. //RemoveUnconsciousnessVignette();
  661. ResetColorize();
  662. }
  663. };