Search Unity

[WIP] Deferred Night Vision Shader

Discussion in 'Works In Progress - Archive' started by GoGoGadget, Aug 8, 2015.

  1. GoGoGadget

    GoGoGadget

    Joined:
    Sep 23, 2013
    Posts:
    864
    Hello,

    Recently I've been getting into shaders, thought it might be a good idea to see if I could get a nice "Night Vision" effect style shader going. By using deferred shading + the diffuse G-buffer texture, it allows for a more 'physically correct' NV effect, I'm pretty happy with the results so far!

    NV On:


    NV Off:


    NV On:


    NV Off:


    Haven't really tried to optimize it at all, but performance is looking good I think?


    The main properties that you can change are the NV color, the "Base lighting contribution", and the "Light sensitivity", so you can have it ArmA-style like in the screenshots, where anything bright gets super washed out, or have it a bit more balanced.
     
  2. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    Real cool looking shader GoGo.
    I was going to mention - how very bright actual lights look through NVDs but including the ability to adjust sensitivity is a nice option.
    I used NVDs back in the day - and one very cool thing about them is how infra red lights interact with the night vision.
    We had infra red (black out) lights on vehicles and these specific lights were invidible to the naked eye but shines like a normal light when viewed under night vision, but do not blow out (bright) like a normal light.
    Also reflective surfaces like reflectors and road signs all light up as if they were IR lights.
    I guess IR could be done with another shader or tag identifier if you decided to include that effect.

    One other option I remember was the ability to switch settings on the NVDs - there were two settings, white hot or black hot. White hot was the most common setting used because everything bright/hot would illuminate (green)white.
    But changing the setting to black hot - which was simply an invert of the highs (white) and lows (black) would actually give some additional detail to the dark areas when lit with white.

    Very cool. Nice work.
     
    GoGoGadget likes this.
  3. MickM

    MickM

    Joined:
    Nov 19, 2012
    Posts:
    166
    Looks very nice and works beautifully in the editor for me but for some reason when I build the game it doesnt work standalone (still works in the editor 'client' though)

    The camera I have it on is a secondary inlaid camera; when forward rendering is used in build settings it still works fine in the editor but not in the builds (the camera just functions as normal)

    In any other rendering (deferred or legacy) the gun camera doesnt even show up in the builds (but still works fine in editor)

    Not too familiar with the tech side there... any ideas?

    Works beautifully in the editor though!!!!
     
  4. GoGoGadget

    GoGoGadget

    Joined:
    Sep 23, 2013
    Posts:
    864
    It should never work with forward rendering, and that second issue is a Unity bug where Unity doesn't respect the depth of deferred cameras, unfortunately.
     
  5. Dr_Who

    Dr_Who

    Joined:
    Jun 5, 2015
    Posts:
    1
    I was having trouble getting the shader to work in standalone as well. Deferred rendering, one camera in the scene but it still failed. Eventually, I found that if you add the DeferredNightVision.shader to the list of "Always Include" shaders in the graphics settings, it will work in standalone. I don't know if this is a bug or just a random occurrence but it fixed it for me! :) Amazing job with the shader!
     
    Bartolomeus755 and GoGoGadget like this.