call
Invokes a reusable function defined by `tslFn`, passing TSL nodes as arguments to execute the same logic at different places in the node graph.
Core Advantages
Its core value is achieving logic modularity and reuse (DRY principle). It allows encapsulating complex node combinations into a meaningful function (e.g., `woodGrainPattern`) and then invoking it with a clear `.call()` in the main flow, greatly improving the node graph's readability and maintainability.
Common Uses
Calling procedural pattern generation functions (e.g., bricks, wood grain)
Executing custom lighting models (e.g., toon shading)
Applying encapsulated complex math formulas (e.g., color space conversion)
Mixing the results of function calls for different material layers
How to adjust
The effect is entirely determined by the arguments passed to `.call()`. For example, for a function that draws a circle, replacing its `center` parameter from a static `vec2(0.5)` to a dynamic vector driven by `timerLocal()` can turn a static circle into a moving animation.
Code Examples
1// Assuming circleFn( { uv, center, radius } ) is defined
2
3// Call the function with dynamic arguments to create a moving circle
4const movingCenter = vec2(0.7, sin(timerLocal()).mul(0.25).add(0.5));
5const movingCircle = circleFn.call({
6 uv: uv(),
7 center: movingCenter,
8 radius: float(0.2)
9});