getCurrentStack
An internal TSL JavaScript helper function that provides global access to the current compilation context (e.g., shader stage, builder) during the build process.
Core Advantages
By providing global access to the compilation context, it greatly simplifies internal node implementations, avoids tedious 'parameter drilling', and allows nodes to easily be context-aware (e.g., distinguishing between vertex/fragment stages).
Common Uses
Implementing stage-specific logic within a node.
Coordinating the declaration and use of Varying variables across stages.
Automatically registering required Uniforms with the builder.
Implementing function definition caching to prevent duplicate code generation.
How to adjust
This is a parameter-less internal function and cannot be adjusted. Its proper functioning is fundamental for TSL materials to compile and render correctly. If it were to fail, it's like a 'nervous system' breakdown, leading to compilation errors or completely wrong effects like incorrect lighting or animations, potentially making objects appear black or as silhouettes.
Code Examples
1// Conceptual usage inside a node:
2const stack = getCurrentStack();
3if ( stack.shaderStage === 'vertex' ) {
4 // Execute vertex-specific logic...
5}