Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static public Vector4 GetZBufferParams (this Camera cam)
- {
- var type = graphicsDeviceType;
- float near = cam.nearClipPlane;
- float far = cam.farClipPlane;
- float x, y, fn = far / near;
- if (type == UnityEngine.Rendering.GraphicsDeviceType.OpenGLES2 ||
- type == UnityEngine.Rendering.GraphicsDeviceType.OpenGLES3 ||
- type == UnityEngine.Rendering.GraphicsDeviceType.OpenGLCore)
- {
- x = (1f - fn) * 0.5f;
- y = (1f + fn) * 0.5f;
- }
- else
- {
- x = 1f - fn;
- y = fn;
- }
- return new Vector4(x, y, x / far, y / far);
- }
Advertisement
Add Comment
Please, Sign In to add comment