setCurrentStack
An internal TSL core function used to manage and switch the current build context (e.g., vertex or fragment shader) during the node graph-to-GLSL conversion, ensuring correct code generation.
Core Advantages
Ensures the generated shader program is structurally correct and logically clear by isolating different build contexts (e.g., vertex vs. fragment, function scopes), forming the basis for TSL's modularity and extensibility.
Common Uses
Switching between vertex/fragment shader contexts in the TSL internal builder
Creating and destroying local scopes when handling function calls
How to adjust
As an internal state management function, incorrectly switching or forgetting to switch the stack will lead to catastrophic build errors, such as writing fragment shader logic into the vertex shader, causing the final GLSL code to fail compilation.
Code Examples
1// Switch to the vertex stack to start building
2setCurrentStack( this.vertexStack );
3
4// ...
5
6// Switch to the fragment stack to continue building
7setCurrentStack( this.fragmentStack );