Fix NVG adjustable brightness (#6291)

Nightvision - Fix adjustable brightness
This commit is contained in:
BaerMitUmlaut 2018-05-31 18:07:31 +02:00 committed by PabstMirror
parent 3d31b6395c
commit 7781c721a8
3 changed files with 16 additions and 14 deletions

View File

@ -19,22 +19,23 @@
params ["_player", "_changeInBrightness"];
TRACE_2("changeNVGBrightness",_player,_changeInBrightness);
private _areEffectsDisabled = GVAR(effectScaling) == 0;
private _brightness = _player getVariable [QGVAR(NVGBrightness), [0, -3] select _areEffectsDisabled];
private _effectsEnabled = GVAR(effectScaling) != 0;
private _defaultBrightness = [-3, 0] select _effectsEnabled;
private _brightness = _player getVariable [QGVAR(NVGBrightness), _defaultBrightness];
_brightness = ((_brightness + _changeInBrightness) min 0) max -6;
_player setVariable [QGVAR(NVGBrightness), _brightness, false];
[format [(localize LSTRING(NVGBrightness)), _brightness]] call EFUNC(common,displayTextStructured);
// Display default setting as 0
[format [LLSTRING(NVGBrightness), _brightness - _defaultBrightness]] call EFUNC(common,displayTextStructured);
playSound "ACE_Sound_Click";
// handle only brightness if effects are disabled
if (_areEffectsDisabled) exitWith {
// here we take (-6; 0) _brightness range and alter it to (0.4; 1.6)
GVAR(ppEffectNVGBrightness) ppEffectAdjust [1, (_brightness+3)/5 + 1, 0, [0, 0, 0, 0], [0, 0, 0, 1], [0, 0, 0, 1]];
// Handle brightness only if effects are disabled
if (!_effectsEnabled) exitWith {
_brightness = linearConversion [-6, 0, _brightness, 0.4, 1.6, true];
GVAR(ppEffectNVGBrightness) ppEffectAdjust [1, _brightness, 0, [0, 0, 0, 0], [0, 0, 0, 1], [0, 0, 0, 1]];
GVAR(ppEffectNVGBrightness) ppEffectCommit 0;
};
// Trigger full ppEffects update next time run in the PFEH:
// Trigger full ppEffects update next time run in the PFEH
GVAR(nextEffectsUpdate) = -1;

View File

@ -80,9 +80,6 @@ if (CBA_missionTime < GVAR(nextEffectsUpdate)) then {
private _grainIntensityFinal = _effectMod * linearConversion [1, 0, _effectiveLight, ST_NVG_NOISEINTENSITY_MIN, ST_NVG_NOISEINTENSITY_MAX, true];
private _noiseSharpnessFinal = linearConversion [1, 0, _effectiveLight, ST_NVG_NOISESHARPNESS_MIN, ST_NVG_NOISESHARPNESS_MAX, true];
private _playerBrightSetting = ACE_player getVariable [QGVAR(NVGBrightness), 0];
_brightFinal = _brightFinal + (_playerBrightSetting / 20);
private _fogApply = linearConversion [0, 1, _effectiveLight, ST_NVG_MAXFOG, ST_NVG_MINFOG, true];
// Modify blur if looking down scope
@ -97,6 +94,10 @@ if (CBA_missionTime < GVAR(nextEffectsUpdate)) then {
_brightFinal = linearConversion [0, 1, GVAR(effectScaling), 1, _brightFinal];
_contrastFinal = linearConversion [0, 1, GVAR(effectScaling), 1, _contrastFinal];
// Add adjusted NVG brightness
private _playerBrightSetting = ACE_player getVariable [QGVAR(NVGBrightness), 0];
_brightFinal = _brightFinal + (_playerBrightSetting / 20);
// Scale grain effects based on ace_nightvision_noiseScaling setting
_grainIntensityFinal = _grainIntensityFinal * GVAR(noiseScaling);
_noiseSharpnessFinal = linearConversion [0, 1, GVAR(noiseScaling), 2.5, _noiseSharpnessFinal];

View File

@ -26,7 +26,7 @@
#define ST_NVG_CAMERA_BLUR_SIGHTS_RIFLE 6
#define ST_NVG_CAMERA_BLUR_SIGHTS_PISTOL 2
#define ST_NVG_MINFOG 0.2
#define ST_NVG_MINFOG 0.2
#define ST_NVG_MAXFOG 0.3
#define ST_NVG_GRAIN_MIN 2.25
@ -45,4 +45,4 @@
#define ST_NVG_NOISEINTENSITY_MAX 0.55
#define ST_NVG_NOISESHARPNESS_MIN 1.2
#define ST_NVG_NOISESHARPNESS_MAX 1
#define ST_NVG_NOISESHARPNESS_MAX 1