Vulkan View Depth from Faramebuffer Depth
Matthew Wellings 18-Nov-2016
This note gives the mathematical derivation of the equation that recovers view space depth in the fragment shaders of the blog post Depth Peeling Pseudo-Volumetric Rendering.
=
This resulting matrix is then effectively pre-multiplied by the view space coordinates to give clip space:
This leads to the following equations for the view space to homogeneous clip space conversion:
After the conversion to Euclidean NDC space the equation for becomes:
or
Then after applying the conversion to window coordinates the transformation remains the same (if you have your minDepth and maxDepth to 0 and 1 respectively):
Rearranging for this becomes:
The terms and are both constant within a shader with fixed projection matrix allowing us to simplify the equation to be resolved in the shader by taking and to give
Matthew Wellings - Blog
Depth Peeling Pseudo-Volumetric Rendering 25-Sept-2016
Depth Peeling Order Independent Transparency in Vulkan 27-Jul-2016
The new Vulkan Coordinate System 20-Mar-2016
Improving VR Video Quality with Alternative Projections 10-Feb-2016
Playing VR Videos in Cardboard Apps 6-Feb-2016
Creating VR Video Trailers for Cardboard games 2-Feb-2016
Playing Stereo 3D Video in Cardboard Apps 19-Jan-2015
Adding Ray Traced Explosions to the Bullet Physics Engine 8-Oct-2015