Shader program helping sources for general maths concepts.
float nkComputeLinearDepth (float nonLinearDepth, float projectionA, float projectionB) ;
Converts a non linear depth value, into a linear expression of that same value, for a given camera. The depth value written to the depth buffer during rendering is not linear and compacts more information closer to 1. To reconstruct depth information in a shader, it is usually necessary to map this "logarithmic" distribution into a linear distribution. This allows to easily reconstruct the position in the camera's field of view.
Parameter | Description |
nonLinearDepth | The non linear depth, directly sampled from the depth map. |
projectionA | The A projection parameter of the camera linked. |
projectionB | The B projection parameter of the camera linked. |
Returns |
The converted value, for the camera parameters given. |
To retrieve the parameters, please check nkGraphics::ShaderPassMemorySlot::setAsProjectionParameters(). They can be directly fed to the method.
- Returns
- The source for the method described.