cameraFar
Provides an auto-updating shader variable equal to the current rendering camera's far clipping plane distance (camera.far).
Core Advantages
Automation and Decoupling. Developers don't need to manually create and update a uniform in the render loop. By simply using this node declaratively, it automatically syncs the latest camera.far value to the GPU, making material logic more independent and maintainable.
Common Uses
Custom Fog: Acts as the endpoint distance for fog calculations.
Depth Normalization: Converts world-space distance to a [0, 1] range for color blending or special effects.
Effect Range Control: Dynamically adjusts the range of depth-based effects like soft particles or shader-based LOD.
Debugging & Visualization: Highlights fragments that are near or beyond the far clipping plane.
How to adjust
This node's value is directly linked to the `camera.far` property in JavaScript. Adjusting `camera.far` dynamically compresses or stretches the effective range of all visual effects depending on it. For instance, decreasing the `camera.far` value (e.g., from 1000 to 200) will make custom fog much denser and appear closer, drastically reducing the scene's visible distance.
Code Examples
1
2// Normalize the distance to the camera using cameraFar to calculate a fog factor
3const fogFactor = saturate( distanceToCamera.div( cameraFar ) );
4
5// Mix the object color and fog color based on the fog factor
6output.color = mix( objectColor, fogColor, fogFactor );
7