positionWorldDirection
Provides a direction vector from the object's pivot to its surface, correctly transformed into world space.
Core Advantages
Its core advantage is correctly handling rotation and non-uniform scale to provide a direction originating from the object itself but expressed in world space, greatly simplifying the implementation of orientation-dependent effects.
Common Uses
Implementing orientation-based procedural coloring, such as making the 'up-facing' part of a model glow in world space.
As a debugging tool, visualizing it as color to intuitively check a model's orientation.
How to adjust
This is a read-only direction node. Adjustments come from taking its dot product with another world-space vector (like `vec3(0,1,0)` or a `uniform`) and then tuning the subsequent processing (e.g., the exponent of a `pow` function) to change the sharpness of the resulting highlight.
Code Examples
1// Calculate the alignment of the model's orientation with the world's "up" direction
2const upFactor = positionWorldDirection.dot( vec3(0, 1, 0) ).saturate();
3
4// Mix colors based on the factor to make the up-facing part glow
5output.color.rgb = mix( baseColor, highlightColor, upFactor );