vertexStage
Computes the input node in the vertex stage and interpolates the result to the fragment stage as a Varying; functionally equivalent to varying(node).
Core Advantages
Explicitly moves computation to the vertex stage to reduce fragment load, and automatically handles vertex→fragment interpolation; clearer semantics and better readability.
Common Uses
Precompute vertex-related, interpolable intermediates (e.g., height/masks/vertex noise) in the vertex stage, then use them in the fragment stage.
Prepare custom varyings for the fragment stage, replacing hand-written attribute/varying plumbing.
Optimization: place costly operations that do not need per-pixel detail in the vertex stage (e.g., position-based weights/masks).
How to adjust
This function has no extra parameters; adjust by changing the input node. The node must be valid in the vertex stage (avoid derivatives or screen-dependent operations that are fragment-only). Mind the number of varyings and interpolation precision limits; keep work in the fragment stage if you need finer detail.
Code Examples
1/* Precompute a height mask in the vertex stage and use it in the fragment */
2const heightMask = vertexStage( smoothstep( 0.0, 5.0, positionWorld.y ) );
3material.colorNode = mix( color( 0x2e7f6e ), color( 0x113355 ), heightMask );