Introduction to TSL (Three.js Shading Language)
devTSL is an approach to productive and maintainable shader creation designed to replace manual GLSL manipulation (like .onBeforeCompile()) with a node-based system.
Key benefits include:
- Renderer Agnostic: TSL can encode code into different outputs such as
WGSL(for WebGPU) orGLSL(for WebGL2). - Automatic Optimization: The system automatically optimizes the shader graph and ensures that shared calculations (e.g.,
positionWorld,normalWorld) are only performed once. - Tree Shaking: Material complexity can be imported into different modules and tree-shaken without breaking the shader process.
- Order Independence: You do not need to worry about the sequence in which components are created; the
Node Systemmanages declarations and inclusions.