positionView
Provides the coordinate of a vertex or pixel relative to the camera (View Space), essential for implementing depth and view-angle dependent effects.
Core Advantages
Its core advantage is placing the camera at the origin, which greatly simplifies depth calculations (e.g., `length(positionView)`) and view vector calculations, making it the most efficient way to implement effects like fog and rim lighting.
Common Uses
Calculating depth to implement fog, making objects fade into the fog color with distance.
Calculating the view vector to implement the Fresnel effect (rim lighting), highlighting object silhouettes.
Serving as the starting point for reconstructing world coordinates in post-processing (e.g., SSAO).
How to adjust
This is a read-only node. Effects are created by operating on its components: use the `.z` component for depth-based fog; use `length(.xy)` for screen-space radial effects (like vignettes); combine it with `normalView` to calculate Fresnel rim lighting.
Code Examples
1// Calculate fog based on the Z-depth in view space
2const cameraDistance = positionView.z.negate();
3const fogFactor = cameraDistance.remap( fogNear, fogFar ).saturate();
4output.color.rgb = mix( objectColor, fogColor, fogFactor );