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