Stack
An identity-style helper: if a current stack is active it registers the input node into that stack and returns it unchanged; otherwise it is a no-op and returns the node.
Core Advantages
Zero-cost side effect. It never alters value or type. It only records the node in the proper build context for later declarations, codegen, or updates.
Common Uses
Collect nodes under an active build stack for unified handling (declarations, varyings, uniform registration)
Drop a capture point in a chain for debugging or usage accounting
Promote a temporary result to the current scope so it is included in the build even if used on a side path
How to adjust
No parameters. The lever is context: call setCurrentStack(...) first to switch to the intended stack, then wrap any node you need to collect with Stack(...). If no stack is active, the call is a no-op and simply returns the node.
Code Examples
1// Add the mixed color into the current stack and drive the material color
2material.colorNode = Stack(
3 mix( color(0x4444ff), color(0xff4444), checker( uv().mul(8.0) ) )
4);