NodeShaderStage
Provides standardized, type-safe constant references for the Vertex and Fragment stages of the graphics pipeline.
Core Advantages
Eliminates error-prone 'magic strings' (e.g., 'vertex') by providing type-safe constants (VERTEX and FRAGMENT). This prevents typos, enhances code readability, and ensures forward compatibility with future TSL library updates.
Common Uses
Conditionally executing logic based on the current shader stage (cond)
Implicitly defining the data flow direction for Varying variables (varying)
Implicitly specifying the scope for Attribute properties (attribute)
Restricting a TSL function to compile and execute only in a specific stage (func)
How to adjust
This node itself is a constant and cannot be adjusted. However, the choice between `NodeShaderStage.VERTEX` and `NodeShaderStage.FRAGMENT` is critical: it determines whether your logic 'changes the model's skeleton (shape)' or 'paints its skin (surface)'. Operations in the vertex stage alter the model's geometry, while operations in the fragment stage alter its per-pixel color or material properties.
Code Examples
1cond( stage.equals( NodeShaderStage.VERTEX ), () => {
2 // Code to execute only in the vertex stage
3} )