ArenMook

ZBufferParams

Dec 1st, 2016
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.54 KB | None | 0 0
  1.     static public Vector4 GetZBufferParams (this Camera cam)
  2.     {
  3.         var type = graphicsDeviceType;
  4.         float near = cam.nearClipPlane;
  5.         float far = cam.farClipPlane;
  6.         float x, y, fn = far / near;
  7.  
  8.         if (type == UnityEngine.Rendering.GraphicsDeviceType.OpenGLES2 ||
  9.             type == UnityEngine.Rendering.GraphicsDeviceType.OpenGLES3 ||
  10.             type == UnityEngine.Rendering.GraphicsDeviceType.OpenGLCore)
  11.         {
  12.             x = (1f - fn) * 0.5f;
  13.             y = (1f + fn) * 0.5f;
  14.         }
  15.         else
  16.         {
  17.             x = 1f - fn;
  18.             y = fn;
  19.         }
  20.         return new Vector4(x, y, x / far, y / far);
  21.     }
Advertisement
Add Comment
Please, Sign In to add comment