I did some test and find out this method only works for perspective camera, with orthogonal we will get divide by zero error((1<<N) * ( a + b / z )). since the distance to camera could be 0 (the z). Maybe we should separate the different camera type as part of the RenderCommandID, then use different ways to generate depth.