Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 22

Thread: Help with Realistic NVG Mod

  1. #11
    Founder Gopher's Avatar
    Lebanon
       Lebanon
    Join Date
    Mar 2012
    Posts
    1,132

    Awards Showcase

    Thanks Thanks Given 
    206
    Thanks Thanks Received 
    113
    Thanked in
    90 Posts
    Recon,

    I am running a triple 24" monitor setup (5760 x 1080 resolution), so 3 times 1920 pixels horizontally, without any other displays (ie MFCD external screens and such). I assume you're running the same (if you're running a triple 27" monitor setup as 5760 x 1080 resolution, then the below will work).

    If so, you need to change nvg_mod.hlsl (included in the NVG mod), as follows.

    Please let me know if this works out for you. Most of the file is the same, take care to read each line between my version and the original one, to see what I have changed. Good luck.


    Code:
    #ifndef NVG_MOD_H
    #define NVG_MOD_H
    
    // Center of the circle used to represent the NVGs.
    //
    // Now let's imagine we use 1000x1000 Pixels as In-game Resolution:
    // And lets say we want the center at 300px from the left and 650px from the bottom.
    //
    // 1000px=1 so 300px = 0.3
    //
    // The Values are starting to count from the Bottom-Left corner of your Res, first is for for
    // Horizontal position and the second for Vertical:
    //
    //
    const float2 EYE_CENTER = float2(0.50000f,0.55000f);
    const float2 MASK_CENTER = float2(0.50000f,0.55000f);
    
    // In precent of screen size.  Since most monitors are not 1:1 aspect ratio most often you will
    // choose your height was the percent value then you take the pixel value of that percentage and
    // divide that by your screen width.
    //
    // Example: Resolution = 1920x1080
    // You want the eye to be 85% the size of 1080.  You take 1080*.85=918, now to figure out same
    // size width take 918/1920=0.4781. Now your circle will be the same width and height.
    //
    // Here are the some numbers for different common aspect-ratios:
    // 4:3 = 1.333 -> Triplehead 4:3 = 4
    // 5:4 = 1.25 -> Triplehead 5:4 = 3.75
    // 16:10 = 1.6 -> Triplehead 16:10 = 4.8
    // 16:9 = 1.78 -> riplehead 16:9 = 5.333
    //
    // First value is for width second for height:
    //
    //const float2 EYE_SIZE = float2(0.5344f, 0.95f);
    const float2 EYE_SIZE = float2(0.17763f,0.94737f);
    const float2 MASK_SIZE = float2(0.53289f,0.94737f);
    
    // How much to scale the image in RENDER_MODE=1. Anything greater then 20% is a bit crazy!
    const float EYE_SCALE = 0.19f;
    
    // Min value to multiply noise.
    const float NOISE_MIN[2] =
    {
      0.5f, // A-10C
      0.75f // KA-50
    };
    
    // Max value to multiply noise.
    const float NOISE_MAX[2] =
    {
      0.5f, // A-10C
      0.75f // KA-50
    };
    
    // Color to use for NVGs.
    const float2x3 COLORIZE_COLOR =
    {
      {0.65f, 1.00f, 0.35f}, // A-10C
      {0.2f, 0.46f, 0.22f}   // KA-50
    };
    
    // Based on the NVG magnification the image is lifted by this.
    // (COLORIZE_COLOR  * nvgmag) * this
    
    const float NVG_COLOR_LIFT[2] =
    {
      0.175f, // A-10C
      0.175f  // KA-50
    };
    
    // Changes the Circle rendering mode.
    //
    // 0 = Circle without zoom
    // 1 = Circle with zoom
    // 2 = Fullscreen without zoom.
    //
    const int RENDER_MODE = 0;
    
    // Enables a slight distortion along the edges of the NVG glass.
    const bool ENABLE_RIM_DISTORT = false;
    
    // Changes the blur rendering mode.
    //
    // 0 = Use default game blur
    //
    // Not yet implemented
    //
    const int NVG_INNER_BLUR_MODE = 0;
    
    ////
    // STATIC VARS
    ////
    
    //
    // NVG Type
    //
    // 0 = A-10C.
    // 1 = KA-50.
    //
    static const int NVG_A10 = 0;
    static const int NVG_KA50 = 1;
    
    const float INNER_RANGE_MIN = 0.950f;
    const float INNER_RANGE_MAX = 0.967f;
    const float OUTTER_RANGE_MIN = 0.979f;
    const float OUTTER_RANGE_MAX = 1.000f;
    const float INNER_RANGE_DIST_MIN = 0.963f;
    const float INNER_RANGE_DIST_MAX = 0.979f;
    float pertween(const float start, const float end, const float value)
    {
      const float range = max(start, end) - min(start, end);
    
      const float a = range - (end - value);
    
      return a / range;
    }
    
    float3 RGBtoHSL(const float3 rgb): COLOR0
    {
      float r = clamp(rgb.r, 0.0f, 1.0f);
      float g = clamp(rgb.g, 0.0f, 1.0f);
      float b = clamp(rgb.b, 0.0f, 1.0f);
    
      float maxV = max(max(r, g), b);
      float minV = min(min(r, g), b);
    
      float h = (maxV + minV) / 2.0f;
      float s = h;
      float l = h;
    
      if (maxV == minV)
      {
        h = 0.0f;
        s = 0.0f;
      }
      else
      {
        float d = maxV - minV;
    
        if (l > 0.5f)
        {
          s = d / (2.0f - maxV - minV);
        }
        else
        {
          s = d / (maxV + minV);
        }
    
        if (maxV == r)
        {
          h = (g - b) / d;
        }
        else
        {
          if (maxV = g)
          {
            h = ((b - r) / d) + 2.0f;
          }
          else
          {
            h = ((r - g) / d) + 4.0f;
          }
        }
    
        h /= 6.0f;
      }
    
      return float3(h, s, l);
    }
    
    float hue2rgb(const float p, const float q, const float t)
    {
      float T = t;
    
      if (t < 0.0f)
      {
        T += 1.0f;
      }
    
      if (t > 1.0f)
      {
        T -= 1.0f;
      }
    
      if (T < 1.0f / 6.0f)
      {
        return p + (q - p) * 6.0f * T;
      }
    
      if (T < 1.0f / 2.0f)
      {
        return q;
      }
    
      if (T < 2.0f / 3.0f)
      {
        return p + (q - p) * (2.0 / 3.0f - T) * 6.0f;
      }
    
      return p;
    }
    
    float3 HSLtoRGB(const float3 hsl): COLOR0
    {
      const float h = hsl.r;
      const float s = hsl.g;
      const float l = hsl.b;
    
      float r = 0.0f;
      float g = 0.0f;
      float b = 0.0f;
    
      if (s == 0.0f)
      {
        r = 1.0f;
        g = 1.0f;
        b = 1.0f;
      }
      else
      {
        float q = l < 0.5f ? l * (1 + s) : l + s - l * s;
        float p = 2 * l - q;
    
        r = hue2rgb(p, q, h + (1.0f / 3.0f));
        g = hue2rgb(p, q, h);
        b = hue2rgb(p, q, h - (1.0f / 3.0f));
      }
    
      return float3(r, g, b);
    }
    
    float3 colorize(const float3 rgb, const float3 to_color): COLOR0
    {
      const float3 hsl = RGBtoHSL(to_color);
    
      const float maxV = max(max(rgb.r, rgb.g), rgb.b);
      const float minV = min(min(rgb.r, rgb.g), rgb.b);
    
      const float lum = (maxV + minV) / 2.0f;
    
      if (lum > 1.0f)
      {
        return float3(1.0f, 1.0f, 1.0f);
      }
    
      return HSLtoRGB(float3(hsl.r, hsl.g, lum));
    }
    
    /*
    float keyHudNVG(const float3 rgb, const float3 krgb)
    {
      const float3 hsl = RGBtoHSL(rgb);
      const float3 khsl = RGBtoHSL(krgb);
      const float satscale = 0.41f;
      const float maxk = 0.0f;
      const float mink = 0.05f;
    
      float2 delta = hsl.xy - khsl.xy;
    
      delta.y *= satscale;
    
      float d2 = dot(delta, delta);
    
      d2 = smoothstep(maxk,  mink, d2);
    
      return d2.x;
    
    }
    */
    
    float3 maskNVGEye(const float2 uv, const float2 center, const float2 size, const float2 res): COLOR0
    {
      float2 pos = float2(res.x * uv.x, res.y * (1.0f - uv.y));
      float2 eye_center = float2(res.x * center.x, res.y * center.y);
    
      float2 eye_size = float2(res.x, res.y) * size;
    
      float2 tmp = eye_size * 0.5f;
    
      float4x2 eye_bbox = {
        eye_center.x - tmp.x, eye_center.y - tmp.y,
        eye_center.x + tmp.x, eye_center.y - tmp.y,
        eye_center.x + tmp.x, eye_center.y + tmp.y,
        eye_center.x - tmp.x, eye_center.y + tmp.y
      };
    
      if (pos.x < eye_bbox[0][0] || pos.x > eye_bbox[1][0] || pos.y < eye_bbox[0][1] || pos.y > eye_bbox[2][1])
      {
        return float3(0.0f, 0.0f, 0.0f);
      }
    
      const float radius = eye_size.x > eye_size.y ? max(eye_size.x, eye_size.y) * 0.5f : min(eye_size.x, eye_size.y) * 0.5f;
      const float aspect = eye_size.x / eye_size.y;
    
      const float dx = pos.x - eye_center.x;
      const float dy = pos.y * aspect - eye_center.y * aspect;
    
      const float distance = sqrt((dx * dx) + (dy * dy)) / radius;
    
      float3 mask = float3(0.0f, 0.0f, 0.0f);
    
      if (distance <= INNER_RANGE_MAX)
      {
        if (distance >= INNER_RANGE_MIN)
        {
          float v = 1.0f - pertween(INNER_RANGE_MIN, INNER_RANGE_MAX, distance);
    
          v = smoothstep(1.0f, 0.0f, v);
    
          mask = float3(v, 1.0f, distance);
        }
        else
        {
          mask = float3(0.0f, 1.0f, distance);
        }
      }
      else
      {
        if (distance <= OUTTER_RANGE_MAX)
        {
          float v = 1.0f - pertween(OUTTER_RANGE_MIN, OUTTER_RANGE_MAX, distance);
    
          v = smoothstep(0.0f, 1.0f, v);
    
          mask = float3(v, 0.0f, distance);
        }
      }
    
      return mask;
    }
    
    #endif

  2. The Following User Says Thank You to Gopher For This Useful Post:

    Snoopy (01Feb15)

  3. #12
    Senior Member Coolhand's Avatar
    United States
       United States
    Join Date
    Feb 2014
    Posts
    567

    Awards Showcase

    Thanks Thanks Given 
    422
    Thanks Thanks Received 
    488
    Thanked in
    252 Posts
    I finally got around to reinstalling the NVG mod last night and worked with the settings a bit to get it like I wanted it to be for flying wing at night.
    Attached is the NVG mod adjusted to 3 monitors running 5760x1080.
    Just extract the contents of the attached zip file to your _Mods directory in DCS that you created to run all your add on mods, then enable it with JSGME, and you should be good to go.

    Note: the NVG with the settings as is will be default round with a smooth heavy rim border.
    I've included two additional files named nvg_mod.2.hlsl and nvg_mod.3.hlsl
    #2 is the same round NVG with the rim border thickness reduced
    #3 is an oval shape that is not realistic, but what I like best flying wing on a dark night with no moon, it lets me keep my lead in the nvg without looking straight at him.
    To use these settings, just simply rename the files to nvg_mod.hlsl
    To change these files, navigate to: DCS\_Mods\NVG_mod\Bazar\shaders\PostMotionEffect\N ightVisionGoogle (<-- not a typo on my part, thats how they spelled goggle)

    Here are a few screenshots of the different settings

    nvg1.jpg

    nvg2.jpg

    nvg3.jpg
    Attached Files Attached Files
    Last edited by Coolhand; 01Feb15 at 17:16.

  4. The Following 2 Users Say Thank You to Coolhand For This Useful Post:

    JayPee (01Feb15), Reaper (01Feb15)

  5. #13
    Member Recon's Avatar
    United States
       United States
    Join Date
    Mar 2014
    Posts
    362

    Awards Showcase

    Thanks Thanks Given 
    170
    Thanks Thanks Received 
    157
    Thanked in
    99 Posts
    Thank you very much everyone! I will try these as soon as I get done with work this week!

  6. #14
    Founder Gopher's Avatar
    Lebanon
       Lebanon
    Join Date
    Mar 2012
    Posts
    1,132

    Awards Showcase

    Thanks Thanks Given 
    206
    Thanks Thanks Received 
    113
    Thanked in
    90 Posts
    And my screenshot with NVGs on looks like this (photo cropped, but you get the idea).

    Last edited by Gopher; 01Feb15 at 18:25.

  7. #15

    Da FAC?


    476vFG GC
    Founding member
    Stuka's Avatar
    Belgium
       Belgium
    Join Date
    Mar 2012
    Posts
    8,363

    Awards Showcase

    Thanks Thanks Given 
    1,277
    Thanks Thanks Received 
    5,892
    Thanked in
    2,565 Posts
    I'm also using option 1 referenced by Coolhand.
    I like the added "challenge" with having a really narrow sight.
    Makes you think twice whether or not you really need your NVG's at that stage in the flight.

    Providing CAS when you're all out of HUA!

  8. #16

    KOVIC


    Founder | 76 vFS | CS
    Snoopy's Avatar
    United States
       United States
    Join Date
    Mar 2012
    Posts
    9,155

    Awards Showcase

    Thanks Thanks Given 
    4,961
    Thanks Thanks Received 
    3,943
    Thanked in
    1,930 Posts
    Quote Originally Posted by Stuka View Post
    I'm also using option 1 referenced by Coolhand.
    I like the added "challenge" with having a really narrow sight.
    Makes you think twice whether or not you really need your NVG's at that stage in the flight.
    Same here.

  9. #17
    Member JayPee's Avatar
    Netherlands
       Netherlands
    Join Date
    Jan 2013
    Posts
    490
    Thanks Thanks Given 
    144
    Thanks Thanks Received 
    78
    Thanked in
    60 Posts
    Option #1 is the mod's default setting, right?

  10. #18

    Da FAC?


    476vFG GC
    Founding member
    Stuka's Avatar
    Belgium
       Belgium
    Join Date
    Mar 2012
    Posts
    8,363

    Awards Showcase

    Thanks Thanks Given 
    1,277
    Thanks Thanks Received 
    5,892
    Thanked in
    2,565 Posts
    I believe it is yes.
    Option 3 is created with stretching the overlay, so you could run into that once creating your own files.

    One very important thing to have a look on:
    In the nvg_mod.hlsl file, you will find an entry
    Code:
    const int RENDER_MODE = 1;
    Change that to
    Code:
    const int RENDER_MODE = 0;
    In the default mode, the mouse pointer in the pit is offset from the actual "click zone". It will drive you nuts within minutes
    By changing that line, you disable that behavior.

    Providing CAS when you're all out of HUA!

  11. The Following 2 Users Say Thank You to Stuka For This Useful Post:

    Coolhand (02Feb15), El_Roto (02Feb15)

  12. #19
    Member JayPee's Avatar
    Netherlands
       Netherlands
    Join Date
    Jan 2013
    Posts
    490
    Thanks Thanks Given 
    144
    Thanks Thanks Received 
    78
    Thanked in
    60 Posts
    Yes but that setting also changes the zoom effect of looking through the lens, right?

  13. #20
    Senior Member Coolhand's Avatar
    United States
       United States
    Join Date
    Feb 2014
    Posts
    567

    Awards Showcase

    Thanks Thanks Given 
    422
    Thanks Thanks Received 
    488
    Thanked in
    252 Posts
    Quote Originally Posted by JayPee View Post
    Yes but that setting also changes the zoom effect of looking through the lens, right?
    Yes, I tried it tonight and the Zoom effect is gone.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Like our website?

You can help us by donating to cover our costs.

Many sincere thanks!


Search

Follow us

Twitter Twitter youtube iTunes Subscribe to our Podcast