stack
stack
Introduces a mutable, stateful local variable into the TSL node graph, solving the difficulty of building up or modifying a value through multiple sequential steps in a declarative environment.
Core Advantages
Common Uses
Building procedural noise in layers (FBM)
Sequentially applying multiple vertex deformation effects
Blending effects like Photoshop layers
How to adjust
Adjust by changing the 'content' and 'order' of what is assigned to it. Adding more `.assign()` operations can add more layers of detail to an effect (like layering noise). Changing the order of `.assign()` statements will completely alter the effect's composition logic, producing entirely different visual results, much like reordering layers in Photoshop.
Code Examples
1// 1. Create a stack node as a mutable container
2const resultStack = stack();
3
4// 2. Calculate an initial circle and assign it to the stack
5const circle = distance( uv(), vec2( 0.5 ) );
6resultStack.assign( circle );
7
8// 3. Create ripples based on the stack's current value and add the result back
9const ripples = sin( resultStack.mul( 50.0 ) ).mul( 0.05 );
10resultStack.assign( resultStack.add( ripples ) );