‘Advanced Night Vision‘ is a highly configurable, AAA quality and easy to use night vision effect. Perfect for FPS and horror games. PC, VR and mobile. Full source code included.
Select the camera you’re going to use (usually called ‘Main Camera‘) in the ‘Hierarchy‘ editor window (1), then click on ‘Add Component‘ button in the ‘Inspector‘ window (2).
Write ‘Advanced Night Vision‘ in the search field, select the effect and add to the camera.
The inspector has these areas:
In the first section (1) you can activate or deactivate the effect (1). You can also define the time it takes to activate and deactivate.
If you click on 6, you will open the online help (this site) and if you click on the “Reset” button (7), many parameters will set to its default values.
This section controls the quality of the effects. If the performance is low, here you can improve it.
- Shader passes [One pass, Multipass]. The number of passes used by the shader. Less passes is faster, but will have less effects.
- Render size [Normal, Half, Quarter]. The resolution of RenderTexture. Lower resolutions are faster, but the quality is worse.
- Blur passes [0 – 10]. Less passes is faster, but the quality is worse. Multipass only.
- Glow strength [0 – 25]. Less is faster. Multipass only.
Blur and Glow effects are disabled if they are 0.
If the small check box is active, the lights will be handled automatically. When the effect is activated, the following occurs:
- All realtime lights that are on in the current scene are turned off.
- A spot light is created that will be the one used while the effect is active. You can configure this light using 1, 2, 3 and 4.
And when turning off the effect:
- The new light goes out.
- All the lights that went out, come back on.
If you want some lights to be ignored in this process, you can add them in 5.
This process should work in most games. But if it doesn’t work on yours you can disable this section and do it manually. Talk to your programmer and tell him to watch the ‘OnSwitch‘ event.
Everything related to the color of the effect.
- Color mode [Simple, Advanced]. The second gives better results but is more complex.
- Tint color.
- Tint color amount [0.0 – 1.0].
- Exposure [0.0 – 10.0]. Higher, brighter.
- Brightness [-1.0 – 1.0]. Advanced mode only.
- Constrast [-1.0 – 1.0]. Advanced mode only.
- Saturation [0.0 – 1.0]. Advanced mode only.
- RGB offset to define the black and white look. Advanced mode only.
Here you can adjust some typical defects of optical equipment: Vignette, Chromatic Distorsion (Multipass only), Noise and Scanlines.
- Types of mask: Screen, Monocular or Binocular. If you select None, turns off the effect.
- Vignette scale [0.0 – 100.0]. How big is the mask.
- Vignette softness [0.0 – 10.0]. How soft are the edges.
- Chromatic distorsion: Advanced or Simple. If you select None, turns off the effect.
- Distortions passes [3 – 24]. Less passes is faster, but the quality is worse. Advanced only.
- Chromatic aberration [-100.0 – 100.0].
- Barrel distortion [-100.0 – 100.0]. Advanced only.
- Analog TV. Simulates the defects of an old analog monitor.
- Noise [0.0 – 10.0]. Noise grain.
- Scanlines [0.0 – 2.0]. Number of scanlines.
- Digital TV. Simulates the defects of a digital monitor.
- Threshold [0.0 – 1.0]. Noise threshold.
- Max offset [0.0 – 1.0]. Noise max offset.
All code is inside the namespace ‘Ibuprogames.AdvancedNightVisionAsset‘ and the main component is ‘AdvancedNightVision‘. So if you want to use it you must first import its namespace:
If ‘myCamera‘ is a valid camera and you want to add the effect, you should do something like:
All the code are well commented, I recommend reading the code if you want more information.
Any questions or suggestions you have, we will be happy to answer you in our mail: