cameraNear
Provides a dynamically updated variable in the shader representing the current camera's near clipping plane distance.
Core Advantages
Automates the data flow by seamlessly syncing the camera's `.near` property to the GPU. This eliminates the need for manual uniform updates, simplifying shader logic and improving code modularity.
Common Uses
Preventing hard cuts from camera clipping (by creating a fade-out effect)
Reconstructing linear depth
Creating near-field triggered visual effects (e.g., energy shields, scans)
Adjusting the starting calculation point for fog or volumetrics
Debugging and visualizing the position of the near clipping plane
How to adjust
This node's value directly reflects the `.near` property of the Camera object in JavaScript. By modifying `camera.near` in your JS code, you can dynamically adjust the starting distance for any shader effects that depend on it, such as changing where an object begins to fade out as it approaches the camera.
Code Examples
1const fadeZoneStart = cameraNear;
2const fadeZoneEnd = cameraNear.add( 2.0 );
3const fadeAlpha = smoothstep( fadeZoneStart, fadeZoneEnd, distanceToCamera );