shaderStages
An internal constant array that defines all shader stages supported by TSL ('vertex', 'fragment', 'compute'). It acts as a 'single source of truth' to ensure code robustness and maintainability by avoiding error-prone, hardcoded strings.
Core Advantages
By providing an authoritative, centralized list of shader stages, it greatly enhances code maintainability (modifying one place affects the entire system) and robustness (avoids bugs from typos in handwritten strings).
Common Uses
During system initialization, iterate through this array to create separate contexts for each shader stage.
Ensure node properties (like uniforms) are correctly declared in all relevant shader code.
Act as a 'whitelist' for input validation to check if a specified shader stage is supported.
How to adjust
This is an internal constant and cannot be adjusted at runtime. Directly modifying the Three.js source code will fundamentally change TSL's capabilities: removing a stage (e.g., 'compute') will disable its corresponding shader type, while adding a new stage (e.g., 'mesh') is the first step to supporting a new shader type.
Code Examples
1// Iterate over shaderStages to create a unique context for each stage
2for ( const stage of shaderStages ) {
3 this.stacks[ stage ] = { /* ... stage-specific data structures ... */ };
4}