/* * generates and stores a depth image rom a z buffer for use in spacial calculations * this is pretty expensive */ public void setDepthImageFromZ(float[] value) { if (cam == null) { return; } if (depthBuffer == null || depthBuffer.Length != value.Length) { depthBuffer = new float[value.Length]; } for (int i = 0; i < depthBuffer.Length; ++i) { depthBuffer[i] = UDUtilities.zBufferToDepth(depthBuffer[i], cam.nearClipPlane, cam.farClipPlane, false); } }
/* * converts the z buffer value to a world space displacement */ float zBufferToDepth(float z) { return(UDUtilities.zBufferToDepth(z, zNear, zFar)); }