Capítulo 799 de 859
On top of the core language (ch797) and built-in inputs (ch798), TSL ships a large library of ready-made helper functions — math/color utilities, texture-sampling helpers, and post-processing effect nodes (bloom, AO, FXAA, afterimage...) callable directly instead of hand-writing the shader graph. This chapter curates the ones you'll reach for most; the full function library is in the hundreds and the rest is best discovered via editor autocomplete on three/tsl.
acesFilmicToneMapping, agxToneMapping — pure node functions equivalent to the renderer's built-in tone mapping, usable inline in a custom post-processing graph.ao(...), afterImage(...), anaglyphPass(...) build a configured *Node/*PassNode instance in one call, instead of new GTAONode(...) + manual wiring.barrelUV, barrelMask and similar distortion/mask helpers for screen-space effects.array(...), attribute(...), attributeArray(...) — construct typed TSL arrays/attributes for custom vertex data or compute buffers.atomicAdd, atomicMax, barrier(scope) — synchronization primitives for compute-shader passes.Math (mirrors ch797's operators but as free functions, e.g. abs(x) instead of x.abs())
| Function | Signature |
|---|---|
abs, sign, negate | (x : Node|number) : Node |
acos, asin, atan(y, x?), acosh, asinh, atanh | (x) : Node |
all, any | (x : Node) : Node<bool> — vector-wide boolean reduction |
and, or, not | (...nodes) : OperatorNode |
bitAnd/bitOr/bitXor/shiftLeft/shiftRight | bitwise ops for int/uint nodes |
Tone mapping & color
| Function | Signature | Notes |
|---|---|---|
acesFilmicToneMapping | (color : Node<vec3>, exposure : Node<float>) : Node<vec3> | Matches THREE.ACESFilmicToneMapping. |
agxToneMapping | (color, exposure) : Node<vec3> | Matches THREE.AgXToneMapping. |
Post-processing effect factories (each returns a configured pass/effect node — pipe into PostProcessing)
| Function | Purpose |
|---|---|
ao(depthNode, normalNode, camera) | Ground-truth ambient occlusion (GTAO). |
afterImage(node, damp) | Motion-trail / afterimage effect. |
anaglyphPass(scene, camera) | Red/cyan stereo anaglyph. |
bilateralBlur(node, direction, sigma, sigmaColor) | Edge-preserving blur, common in denoising/SSAO pipelines. |
billboarding(config) | Camera-facing quad orientation node. |
Data / compute construction
| Function | Signature |
|---|---|
array(valuesOrType, count?) | → ArrayNode — fixed-size TSL array. |
attribute(name, nodeType) | → AttributeNode — read a custom vertex attribute by name. |
attributeArray(count, type) | → StorageBufferNode — GPU storage buffer for compute passes. |
barrier(scope) | → BarrierNode — compute-shader memory/execution barrier. |
atomicAdd/atomicMax/atomicMin/atomicOr/atomicAnd/atomicXor/atomicLoad/atomicStore/atomicSub | (pointerNode, valueNode?) : AtomicFunctionNode |
ao, afterImage, anaglyphPass, ...) already exists — check the function library before hand-rolling.barrier() in compute passes — cross-invocation reads/writes need explicit synchronization or results are undefined.add(a, b)) and method-chained form (a.add(b)) are equivalent — pick whichever composes better for a given expression.PostProcessing graph, not a fixed EffectComposer pass list — this is more flexible than the classic EffectComposer/*Pass API (also documented, see the Renderers & Post-processing chapters).atomic*, barrier, attributeArray) are WebGPU-only — they no-op or error under the WebGL2 fallback.three/tsl autocomplete or the official TSL reference when this chapter doesn't have what you need.normalView/positionView internally.EffectComposer pipeline these functions parallel.