depthPass
The depthPass node performs a special rendering pass that does not output color, but instead records the depth information of each pixel relative to the camera into a texture (a depth map).
Core Advantages
Provides critical scene geometry data to shaders, forming the foundation for advanced visual effects like Screen-Space Ambient Occlusion (SSAO), Depth of Field (DoF), soft particles, and for performance optimizations like Z-prepass.
Common Uses
Screen-Space Ambient Occlusion (SSAO)
Depth of Field (DoF)
Soft Particles & Water Interaction
Custom Shadows
How to adjust
The effect of depthPass is primarily adjusted within the shader that consumes its output. Common methods include: 1) Applying mathematical functions like `pow()` or `smoothstep()` to the sampled depth value to control the intensity and transition range of effects (like fog or DoF). 2) Offsetting the UV coordinates when sampling the depth map to achieve effects like SSAO or distortion.
Code Examples
1const depthValue = texture(sceneDepthPass, uv()).r;
2
3// Calculate a factor from 0 to 1 based on depth
4const effectFactor = depthValue.smoothstep(0.4, 0.9);
5
6// Mix the original color and effect color based on the factor
7return mix(sceneColor, effectColor, effectFactor);