getNormalFromDepth
Reconstructs scene surface normals in a post-processing step using only a depth map and camera parameters, providing essential geometric data for screen-space effects like SSAO and SSR.
Core Advantages
Encapsulates a high-quality, edge-aware normal reconstruction algorithm, allowing developers to easily obtain crucial normal information in post-processing without writing complex shader code or using Multiple Render Targets (MRT).
Common Uses
Screen Space Ambient Occlusion (SSAO)
Screen Space Reflections (SSR)
Post-process lighting (e.g., Deferred Lighting)
Debugging and visualizing normal maps
How to adjust
This node has no adjustable parameters. Its output quality depends entirely on the accuracy of its inputs: it requires the correct UV coordinates for the current pixel, the corresponding scene depth map, and the inverse projection matrix that exactly matches the camera used to generate that depth map.
Code Examples
1// Reconstruct normals from depth, UVs, and the camera's inverse projection matrix
2const normal = getNormalFromDepth( [ uv(), depthTexture, cameraProjectionMatrixInverse ] );