Realistic nightvision shader

Realistic nightvision shader

Postby Caligari87 » Sun Dec 15, 2019 10:38 am

Originally created to replace the stock nightvision goggles shader in Hideous Destructor, but should work for anything else as well, provided you write a script and GLDEFs to activate it.


Note: Click through for full resolution, the scanlines look odd downscaled. Screenshot shows the dark edges from Hideous Destructor's goggle overlay, which is not included with this shader.

nitevis.fp [Github Gist]

Features
  • Customizable resolution downscaling / pixelization
  • Optional horizontal and / or vertical scanlines
  • Customizable color filtering with two color modes and white clip levels

Usage
Your script must pass a custom exposure uniform to the shader, or else nothing will happen. The expected exposure value is an integer between -100 to 100, but should theoretically work with floats and higher numbers if desired. Positive values activate the primary color filter, negative values activate the secondary color filter. A value of zero disables color filtering and light amplification, but retains scanlines and pixelization.

The user-customizable values at the top of the shader should be self-explanatory, but are listed here for convenience. These are hardcoded by default, but if you're familiar with shaders it shouldn't take much to make them dynamic.
  • resfactor: Divides the native screen resolution by this amount. For example, if your game is running at 1920x1080, a resfactor of 4 will produce a virtual resolution of 480x270.
  • hscan/vscan: Enables horizontal and/or vertical scanlines. These are 1 real (not virtual) pixel thick, rendered black.
  • posfilter/negfilter: Color filters for positive and negative exposure values respectively. These are relative RGB channel strengths in the range of 0-1, but will be normalized by the shader, so (5, 2, 1) becomes (1.0, 0.4, 0.2).
  • whiteclip: Adjusts the "white value" of the brightest screen areas, with 1.0 being pure white, and 0.0 being the dominant filter color. Values above 1.0 are valid, as are negative values. Both can provide unique and interesting effects.

Limitations
Please note the exposure curve on this shader is exponentially strong and meant to simulate realistic nightvision capabilities. Even at even moderate exposure values, typical Doom levels may become blindingly white.

The shader may not be able to amplify pure (0,0,0) black values. A minimum sector light level of 1 is recommended (My other project, DarkDoomZ, can be used to help enforce this if your project does not use custom maps). Some other method like attaching a very very dim dynamic light to the player when the shader is active can work as well.

There are no grain/static/noise effects, but these could be added if you wish to pass a timer uniform to the shader. Vignettes like the one seen in the screenshot are also left as an exercise for the user.

So far as I'm aware this code is my own, and is under the very permissive zlib license. You may use or modify this shader freely, provided the license and copyright notice remains intact.

8-)
User avatar
Caligari87
I'm just here for the community
User Accounts Assistant
 
Joined: 26 Feb 2004
Location: Salt Lake City, Utah, USA
Discord: Caligari87#3089

Re: Realistic nightvision shader

Postby 3336655445 » Fri Dec 27, 2019 7:14 am

what the weapons mod?
3336655445
 
Joined: 25 Jul 2019
Location: Odessa
Discord: Счастливая трубка
Operating System: Other OS Not Listed Here
Graphics Processor: Not Listed

Re: Realistic nightvision shader

Postby Caligari87 » Fri Dec 27, 2019 3:43 pm

User avatar
Caligari87
I'm just here for the community
User Accounts Assistant
 
Joined: 26 Feb 2004
Location: Salt Lake City, Utah, USA
Discord: Caligari87#3089


Return to Shaders

Who is online

Users browsing this forum: No registered users and 1 guest