Skip to content

Instantly share code, notes, and snippets.

@nobnak
Created February 27, 2016 05:58
Show Gist options
  • Save nobnak/f349a3d764ed80d23a65 to your computer and use it in GitHub Desktop.
Save nobnak/f349a3d764ed80d23a65 to your computer and use it in GitHub Desktop.
Depth Buffer -> Linear Eye Depth for Unity
#ifndef __DEPTH_CGINC__
#define __DEPTH_CGINC__
float Z2EyeDepth(float z) {
return unity_OrthoParams.w < 0.5
? LinearEyeDepth(z)
: ((_ProjectionParams.z - _ProjectionParams.y) * z + _ProjectionParams.y);
}
#endif
@TheSeanLavery
Copy link

Hello, I am kind of new to shaders. Could you help me implement this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment