I'm running into contradictions while attempting to build a projection matrix for Vulkan, and have yet to find an explanation for how the projection matrix should map Z from input vector to the output. Mapping x and y is straightforward. My understanding is that OpenGL Projection matrices should map the near frustum plane to -1, and far to +1. Vulkan to 0 and +1 respectively. The mapping should be logarithmic, allowing greater precision in the near field.
The examples below use near (n) = 1, far (f) = 100. Here's a plot of z mapping using a matrix I constructed to the Vulkan spec. It produces errors in rendering, but produces the correct result as I understand it:
lambda z: (f / (f-n) * z - f*n/(f-n)) / z
A plot of the most common OpenGL projection I've found online, which should map from -1 to +1:
lambda z: ((-f+n)/(f-n)*z - 2*f*n/(f-n))/-z
And here's one generated from a lib I use, for OpenGL (cgmath in Rust):
I'm unable to build a proper Vulkan projection matrix (Of which I've found none via Google) unless I understand what z should map to. I suspect this is due to an implicit correction done post projection matrix by the shader that actually maps to the ranges I listed, but if so, I don't know what range to feed into it via the proj mat.