bypass
A utility node that executes a separate action (a side-effect) while passing a primary data value through the node chain, effectively separating the 'data flow' from the 'action flow'.
Core Advantages
It elegantly enables imperative operations, most commonly variable assignment, within TSL's declarative, chainable syntax without breaking the flow. This greatly enhances code readability and organization, providing the standard way to handle side-effects.
Common Uses
Assigning a value to a variable (VarNode) in the middle of a complex calculation chain.
Performing pre-calculations: computing and storing values (like lighting factors) early in the pipeline, even if the main flow doesn't need them directly.
Creating a non-destructive debug probe: assigning an intermediate result from a node chain to a debug variable without interrupting the main calculation.
How to adjust
This node's direct output value is always identical to its first argument (returnNode). Visual changes come from the side-effect produced by its second argument (callNode). For example, you can pass a red color through bypass while its side-effect stores a noise value in a variable. This variable can then be used in other calculations, indirectly affecting the final image, while the bypass node itself just 'transparently' passed the red color.
Code Examples
1// Create a variable to store the result of the side-effect
2const myVar = vec3().toVar();
3
4// bypass() executes the myVar.assign() action, but its own output value equals someColor
5const flow = bypass( someColor, myVar.assign( uv().extend(0) ) );