Night vision shader for anomaly re-imagined. Now features MCM settings to adjust NVGs to your taste, a totally rewritten rendering pipeline, and a bunch more.
* Breaking News*
New update in the works. I won't hit everything on the roadmap listed in first comment but will additionally add DX8/9 support (minus some features that are computationally expensive), as well as some other fixes.
Thanks to F.E.A.R and Haruka for Russian translation
Introduces a shader based NVG effect to Stalker Anomaly, instead of the more limited .ppe effect. Currently replaces Gen1 thru Gen3 head mounted NVG effects. Can be expanded by modders to create additional effects, such as non-fullscreen NVG scopes and other possibilities.
New Keybinding: Long press "N" (or your nightvision keybind) to enable/disable NVGs, short press to adjust brightness
Follow future developments at Github.com
**********************************************
MUST READ THIS SECTION
**********************************************
Functions on DX10/11 only - future DX8/9 compatibility is possible, but I'm not touching it just yet.
After installing this mod or making any adjustments to night_vision.h, you must restart the game and select DELETE SHADER CACHE or changes will not take effect. The Anomaly launcher recompiles its shaders from the gamedata/shaders folder ONLY if this option is checked. Once you have done this once, you will not need to do it again unless you make changes to head_mounted_nvg_shader.h or other shaders.
**********************************************
END MUST READ
**********************************************
Installation Steps:
- If you have Glossy SSR, Enhanced Shaders, Arszi Rad overhaul, place these before Beef's NVGs
- Install Beef's NVGs
- If you are using Glossy SSR and Enhanced shaders, , use the included patch. now (currently the patch included with those mods is for NVG v0.9 and will not work)
- If you are using Enhanced shaders but not glossy SSR, use the included patch now.
- If you are using Glossy SSR but not enhanced shaders, use the included patch now.
- If you are using Arszi's rad overhaul, use the included patch now.
- Configure MCM
- Calibration per-PC is still in its draft stage, a better process is in the works but this is one way to do it.
- First, load up in debug mode
- In MCM menu, turn min gain as high as it goes, and max gain as low as it goes
- Go outdoors in some map and change the weather to clear_1 and time to midnight
- Turn on Gen 3 NVGs and adjust the gain offset higher or lower until the moonlight on the ground and buildings just barely doesn't wash out - after changing MCM setting you have to turn off and back on the NVGs for it to take effect
- Change the weather to cloudy_2_dark change max gain to 2, then turn off and on the NVGs. Quick press N until you are at the brightest setting. You should be able to see outside "ok" with Gen 3 but somewhat poorly with gen 1 and gen 2. If you want more brightness you can increase max gain slightly more. If you want to focus on 'gameplay' and don't like the 'realism' then go back to step 5 and increase your gain offset so that the 'base' brightness is higher, then come back to step 6 and so on.
- Change the time to noon and keep the weather on cloudy_2_dark. Quick press N until you are at the lowest setting. Adjust the min gain in MCM lower until you can see during the day (should be somewhere between 0.3 and 0.5 generally)
- Adjust the number of tubes per generation as you see fit, as well as the overlays you want
- Close out the game and turn debug mode back off, and you shouldn't need to adjust NVGs any more other than with a quick press of the nightvision keybind when you enter bright or dark areas.
- Profit
Intent:
I want to create NVGs for Stalker that mirror real-life NVGs, without overdoing it. Likewise, I also want these NVGs to be highly configurable, to allow users to edit them without having to dig through files to change lines of code. To achieve this, I created this shader-based NVG effect to fill what I saw as a missing piece of the Stalker experience.
v1.1.1 Chagelog:
- Fixed small chance of NVG's enabling before RegisterScriptCallback completed, causing the NVGs to get stuck in the "up" position, thanks to Lenny for coming across this
v1.1 Changelog:
- Now uses renamed folder structure from Mr Minotaur for better compatibility with MO2 and future updates.
- Added NVG turn-on animations
- Added NVG shader animations
- Now requires shader_param_7, so its 100% not compatible with Enhanced Shaders Color Grading full shader controls, only the simple controls (or no controls)
- Added controls for radius and vertical positioning of NVGS (for animation / scope compatibility)
- Improved compatibility with Shader Based 2d Scopes (alternate sights still need fixing)
- Improve performance potentially by unregistering unused callbacks when NVGs are disabled
- Added additional checks to prevent issues when turning on / off NVGs while ADS and other actions
- Fixed issue with glossy SSR patch
- Fixed binocular compatibility
- Added sound to brightness adjustment action
v1.0.1 Changelog:
- Added compatibility option for Shader Based 2d Scopes into MCM menu
v1.0 Changelog:
- Complete rewrite, added MCM Support
- Separated image / lightmap /albedo as inputs to rendering
- Updated comments in night_vision.h for advanced user-adjustable settings
- Added separate sky adjustment to night_vision.h
- Glitch effect from blowouts added
- Auto-turn off NVG when PDA opened functionality (MCM configurable)
- Prevent NVG's from enabling when ADS (MCM configurable)
- Compatibility with Glossy SSR / Enhanced shaders
- Russian localization
- Ability to set the number of tubes in each generation (MCM configurable)
- Probably a lot more that I forgot
Previous Changelog:
- v0.9 - complete rewrite, introduces tons of new bugs, but improves performance/adjustability
- v0.85 - updated for RC19 compatibility - patches may be out of date
- v0.84 - updated all compatibility patches for Feel_Fried's animations
- v0.83 - version update for the people who downloaded .82 before I ninja-updated an error
- v0.82 - added compatibility patch for Nav's Definitive Masks
- v0.81 - added two new configurations, brighter and brighter+arcade
- v0.8 - fixed distortion, improved effects, implemented new features, uploaded to MODDB
Not a bug regarding beef's mod, but if you use a retexture for gunsight reticles, you run the risk of having bloom become overwhelming to the point you may not be able to use the optic at all during NVG use.
I am using bert's Moddb.com for reference, and the Kobra sight retexture is unusable on anything below a threshold for washout setting of 0.9. Again, not an issue with this mod and removal of the offending sight texture will fix the issue, but it's something to keep in mind perhaps. Everything else seems to be working as intended on the v1.0.1 release of Beefs NVG's for 1.5.1.
In chasing realism sometimes it makes things more complex in a game. The easiest answer is to get adjustable brightness for the scope reticles so they can have a day and a night mode ... it's on the 1.2 figure-out-how-to-do list anyway, perhaps triggered by turning on NVGs. Green lasers and sights from B&S also get washed out but red do not (as much) due to the YUV conversion that I use to pack the image data into a single channel in order to manipulate the lightmap and albedo in the other two color channels.
I hope you're able to keep making progress on your mod and don't run into any more issues now that you've gotten it into a state you're happy with. I was able to add v1.0.1 to my extensive load-order today thanks to the newly found compatibility for other mods, including shader-based 2d scopes and if I'm not misremembering, Food, Drugs & Drinks animations and perhaps Groks masks. I've played with it a little more since installation and noticed binoculars have trouble displaying properly under NVG unless you activate it post-zoom.
I'll try to keep track of any other issues I may find during testing, and I'm eager to see what else you do, Beef's NVG's or otherwise. :D
Edit: Just a stray thought, but perhaps either as a part of or post-release of v1.2, you could redo binoculars entirely as an optional addon as they have NVG upgrades. It occurred to me when I saw you were also considering tweaking other devices/items.
I've added fixing the binoculars to the todo list for 1.1, thanks for the heads up
As far as the long term nvg upgrades for bino stuff, its also a pretty good idea, but I have to keep 'scope creep' or whatever its called within check, so that I finish what's in front of me before adding too much to the todo list, but its not a bad idea. Thanks for sharing :)
This is awesome great work! Adjusting brightness is wonderful, would it be possible to add a sound to that?
Definitely looking forward to the fix for those thermal colors, at least turning scope_blur_inner to 0 is a quick temporary fix. I'm not sure if you already know, but there seems to be a bug where if you have NVG on and then look through the binoculars, it's just black. Works find if you look through binocs and then turn NVG on. Maybe just me.
In next update the shader scopes patch will keep your original scope_blur_inner value when you don't have nvgs, and disable it when you are using nvgs, then restore it afterwards.
Adding a sound to brightness adjustment is a good idea, I've added it to the v1.1 todo list
I also added fixing the binocular error to the 1.1 todo list.
Hey think I found another lil bug, using Gen 3 night vision & if I zoom in it changes from a quad tube to a single tube, same if I switch from scope to iron sights with Alternate Aim mod. When I zoom back out it switches back to a quad tube. If I zoom in then turn NVG on, it's quad tube with the thermal-looking colors outside, but when I zoom out and zoom back in it's back to single tube. (I don't remember if that was happening a few days ago when I installed, but don't think I changed anything either.)
I did this when shader scopes is enabled as my only real option with shader 2d scopes because there's some conflict with the two shaders that I can't easily resolve, so when you zoom in and shader scopes takes over it needs to switch to a single tube or the data packing gets displayed instead of the actual NVG image.
I've got some progress to make on differentiating between the shader 2d scopes and ironsights
That's better than nothing or wonky colors I suppose. Would it be possible to make it differentiate between scoping in with the scope and scoping in with iron sights through Alt. Aim mod? If not, same as above...
(Normal iron sights with no scope attached work fine, to clarify.)
Bloodsucker's seem to have the washout effect from lights applied to them when they are cloaked, makes those suckers even easier to kill with NVG, unfortunately.
I.imgur.com
I'll take a look at the alt sights
As far as bloodsuckers...damn
I'll see if I can do anything about this, but if not then I'm gonna chalk it up some explanation like 'their skin absorbs visible light and emits it in NIR band so that they can become invisible but if you're wearing NVGs then they show up better' or some **** and call it a feature not a bug ;)
"call it a feature not a bug ;)"
Yes, I am familiar with the S.T.A.L.K.E.R. games =P
Honestly it is still a little difficult and jarring, you go from able to track them when they are invisible to suddenly having to adjust to them not being a washed out blob when they get closer and attack. Especially difficult if there are other washed out blobs of light around you.
Question, is there a way to change the colors of each generation? I kinda digged the way My Little NVGs did the colors for each generation so I thought that it would be nice to change Gen 2's green hue to a blue hue and change Gen 3's blue hue to a white hue.
Nevermind, trawled the comments for the v0.9 version, didn't know that night_vision.h had all of the variables I would need to change toa adjust each generation's color. Now I feel a bit like a dummy, especially since I tried to open the .ps files with GIMP, lol,
No worries, in 1.2 after some of the other shader mods reduce the number of shader params they use, I'd like to add MCM sliders or options to adjust each NVG generation color settings so no editing of night_vision.h is necessary. However, even with data packing, it requires at least 2 more shader_params to be available to fit all the stuff I'd like so it won't be in the next patch just yet so that I don't hog up all the space.
If you made your own color setting that you like the look of, I'd love to hear what you ended up.
I just copied the examples you had typed down under the saturation values, lmao.
I recognized that it was using RGB but I was unfamiliar with how the numbers worked (used to the RGB code of 255,255,255 for example, not the numbers of 1.0,1.0,1.0) so I just aped what I saw.
EDIT: Also appreciate your work man! Its nice that you have everything commented out in night_vision.h.
Take the 0 to 255 number that you choose in RGB scheme (say 155) and divide by 255. It'll give you a number between 0 and 1, and that's what shaders can take for inputs.
Hey beef how exactly do I clean uninstall the original shader based NVGs. I don't use MO2 for stalker.
Never mind I got it to work because I am pro manual installer. Only thing left is that BaS sights are blown out like every other light source but somehow I was able to turn off the illumination on the reticle?? The illumination came back however. Could you make an optional patch for BaS sights or some key bind to illuminate your sights because that definitely seemed like a feature.
I have some ideas for later, but for now as some others noted above simple increase the washout threshold until your sights no longer washout.
Could you do NVG Aim Down Sights pistol only? Thank you in advance
Hmm I guess that's not unreasonable, as it somewhat splits the middle. Probably in 1.2 as I'd like to release 1.1 sometime sooner than later and I have a lot on the todo list still. Assuming it's fairly quick like a IsClassPistol(obj) sort of check yeah, and I may consider expanding it into an ADS all sights, ADS iron sights, ADS pistol only or something similar ...
Hi Beef, awesome mod!!!! I have one question (and it might have been asked before): Can we have a setting in MCM to adjust the blurryness of people etc. while using the NVGs? I like that objects are blurry, but it's a bit too much for me. Maybe a slider or so would be nice...
just an idea.
cheers!
It's planned for v1.2 to get a 'disable dof' setting into MCM ... just have to figure out how to pack more data into the same number of floats is all ...
cool! But "disable" might be a bit too strong for my taste. A slider would give more flexibility. but I understand it's also a lot more work!!
In the meantime, if you're feeling experimental, you can decrease this value I've circled in pp_blur.ps.
Change it from
float scale = 0.3f;
to something like
float scale = 0.15f;
and it will decrease the total 'amount' of blur slightly.
Link to screencap: Imgur.com
I've minified the shader a bit just to be able to see the bigger picture when putting all the shaders together, but if you're curious about the original blur, it's an implementation of my `IGN + Vogel - Chaos` blur that you can see on Shadertoy (Link: Shadertoy.com). Pass 1 here takes Luma and Lightmap and adds a blurred depth buffer to the blue component of RGB image in order to provide a slight 'halo' around objects in second pass of DOF so it's not a sharp cutoff, and pass 2 is the actual 'blur'.
wow. that is very impressive! I'll play around with the float scale a little!
Excellent mod! Only a little hint: when aiming through a scope the nvg turns off but it can be reactivated by pressing "n" again. I think this needs a restriction. An the nvg should not turn off when aiming with irons sights or a kobra scope...
In the MCM options you can determine whether NVGs stay on while ADS or not.
That you can 'override' it is a good bug, I need another check there, thanks :)
Also, being able to select whether it stays on in iron sights / optics / etc is a further step that I'd like to take, but probably in 1.2 since I'm not yet sure how to differentiate between scopes / ironsights.
In general, aiming down sights with night vision is basically impossible IRL due to the limited depth of field that they present, and is why IR lasers are the norm for night operations. (Or actual weapon mounted night vision / thermal scopes). When B&S gives the ability to turn on/off lasers for weapons (Haruka already coded this) it'll be a lot more useful feature as well.
Now, i have an account :)
Thanks for your reply! With "2d shaderbased scopes" i found out it is possible to differentiate between ironsights,kobra and scopes... in the script "fakelens.script" the mod is searching for the scopesRadii value. If it doesnt find a value then it is an ironsight. Maybe this is an approach... Speaking of 2dshaderscopes, i solved the issue with the night scopes with the help of the "night scopes toggle" mod. The key is to set the scope_factor to 1.0 while aiming. It works well.
Thanks for the extra feedback, it could turn out helpful for next update :)
Wow, 1.0.1 is such a massive improvement over 0.9, thanks Beef, I love it!
The biggest disappointment for me was putting on nvgs for the first time and absolutely hating them. 9.5/10, muh realism
! c:/s.t.a.l.k.e.r. anomaly\appdata\shaders_cache\r4\pp_blur.ps\2048111100110000001000100000110334112110141000
! error: common_functions.h(54,34): warning X3206: implicit truncation of vector type
common_functions.h(74,2): warning X3206: implicit truncation of vector type
common_functions.h(79,49): warning X3206: implicit truncation of vector type
common_functions.h(111,2): warning X3206: implicit truncation of vector type
gbuffer_stage.h(123,24): warning X3206: 'Load': implicit truncation of vector type
gbuffer_stage.h(124,23): warning X3206: 'Load': implicit truncation of vector type
night_vision.h(2,17): error X3003: redefinition of 'shader_param_8'
If you have a redefinition of `shader_param_8`, then there's some conflict with another shader. (The other warnings are all vanilla issues, but are warnings not errors)
Some of the possible solutions I've come across with others
- Make sure you disabled v0.9 completely
- Make sure you aren't using B&S NV scopes that rely on v0.9
- Make sure you aren't using the NVG patch from ES or Glossy SSR, since their included NVG patches are for v0.9.
Love it. Would love an option for fisheye optic for the true realism so aiming is more difficult, because I hate myself.
11/10 How can ppl play without this
Hmm, a fisheye optic is something I hadn't though about, not sure how it would look but it sounds kind of cool. I put it on the intriguing ideas list to look at after 1.1 is done. Also not sure how it would effectively be applied with dual or quad NVGs. Interesting idea nonetheless
So Gen 1 NVGs have the fisheye optic because of crappy lenses, it's rare to see that in Gen 2 and Gen. For extra realism you could also add artifacts on Gen 1 NVGs. I know you can add Textures on ReShade but I'm not sure how it goes with NVGs.
When I talk about artifacts in NVGs I'm meaning blemishes and Black Spots. They are smol bois you mainly notice when looking on a plane field but they're there. Manufacturing issues
About Gen 2 and 3 - afaik and that's info from my comrade who's been serving a bit longer than me - Gen 2 and 3 are basically made to be of good quality. So basically crappy lenses, artifacts will be rarer on Gen2 and pretty much non-existent on Gen3 NVGs. Hope I could add some more insight
Thanks, this is all helpful - I'm basing Gen 1/2/3 in-game off of gen 2/3/3+ IRL, if its worth something to you. An actual "gen 1" sort of device is basically worthless without IR illuminator.
I would like to incorporate autogating as well into the in-game gen2 and gen3 devices, but that will come later.
Hey there Beef, idk how to describe the problem per se, but long story short:
Im using the mods:
* Tacticool Scopes
* Shader Driven Scopes
* this fix:https://www.moddb.com/mods/stalker-anomaly/addons/shader-based-2d-scopes-radius-fix-for-tacticool-scopes
and your mod... with patches for ES + SSR
For some weird reason, the "fix" it's not working when i toggle NVG ON, the shader is bigger than the scope image, it doesn't happen when ADS with NVG OFF... tried playing with the load order a little but no luck...
EDIT: added some images:
Imgur.com
Hey, thanks for providing an image since it helps a lot trying to figure out what's going on.
Assuming you've got the "Shader Driven Scopes" compatibility enabled in the MCM menu, the issue is going to be that the radius isn't correct.
When you ADS with the NVGs enabled and Shader Scopes Compat clicked in MCM menu (and have the 'allowed to ADS with nvgs'), the NVG reads the same radius file that Shader Driven Scopes uses for its stuff, in order to match it. If the NVGs are showing up outside, then most likely either the radius isn't set right in file or the compatibility isn't checked.
A final possibility is that the callbacks weren't working right on some systems (which I fixed in v1.1.1) and this could be the source.
Let me know how it goes and what fixed it :)
heya Beef!, forgot the mention that, the MCM option is enabled, this "behaviour" was introduced when i updated to the last version of this mod, wasn't happening before. Also i tried to move the "fix" file alone to the folder of your mod, and nothing. lol.
i can live with it, no worries, just letting u know hehe
I just deleted shaders cache and BAM! everything is fine now! thanks beef!
Really nice additions with the recent updates! Great work!
with the latest update found FPS drops (10)
FPS drops with NVGs enabled or disabled? And do you have Glossy SSR?
If FPS drops are regardless of NVG state, its because I messed up the math for Glossy SSR Patch in previous version when trying to disable SSR inside NVG radius (since it makes extra washout), and the FPS drops can be associated with the SSR.
Nothing substantial changed on the shader side, just adding a couple of floats that can be adjusted by console, and on LUA side there isn't any 'heavy' function running.
For testing, I left only your addon active. FPS drops remained. This started in version 1.1.1. Before that, everything was fine.
This is too vague to go on - do your FPS drops occur with NVGs turned on or turned off? There's nothing changed in shaders that could possibly take an additional 3ish milliseconds (the difference between 60 and 50 FPS, since you didn't indicate what the drop is to/from).
So if it does occur, it would have to be LUA related, and unless unregistering callbacks that are not in-use somehow negatively impacts performance, which seems not likely since it completely disables the script when NVGs are turned off, then I'm not so sure it's related to this mod, but instead to the hundreds of other settings that you can change in Anomaly
Fps drops when NVG is turned on. There are no addons that change shaders.
Same problem
ZeD_MnizD "Fps drops" is about as helpful as stating "game crashes" or "computer running".
Without the detail I've asked you for this is a meaningless statement and the fact we're 3 messages deep without numbers is wasting my time.
Of course there is a cost to turning on NVGs - as an example I drop from 55 to 52 FPS in Cordon when turning on NVGs, but its the same cost as it was in 1.0.1 as it is in 1.1.1.
If you claim there is some difference in the performance of 1.0.1 and 1.1.1, then stick with 1.0.1 until you can provide better information.
(Google translate)
I repeat. For testing, I launched Anomaly only with your add-on, without Glossy SSR and other add-ons that change shaders. The fall in FPS occurs when the NVG is turned on. What other additional information do you need?
The framerate you get without NVG turned on, and with NVG turned on please. If you can, the same values but for 1.0.1 as well, since you say there is a difference.
To understand why I need this - the NVG shader runs in ~1.05ms on my Nvidia 970m with DX11. There will always be some level of 'cost' with the additional visual effects. With a bunch of other visual mods, and most visual settings maxed is the difference between 55 and 52FPS, but if I have all the graphical settings lowered down, it is also the difference between 120 and 107FPS, because the NVG shader takes the same amount of time regardless.
But the performance difference seems larger when you are losing 13FPS at a high framerate vs losing 3 FPS at a low framerate. Without some kind of context I can't know if there's a problem or not that needs to be resolved.
For comparison's sake, in Reshade the PPFXBloom takes 1.7ms to run.
I am sending you screenshots.if you need some other way of demonstration, please inform.
Drive.google.com