convertToTexture
A powerful utility function that 'snapshots' or 'bakes' the visual output of any TSL node graph into a reusable texture, fully automating the tedious manual 'Render to Texture' (RTT) process.
Core Advantages
Its ultimate abstraction. It encapsulates all complex, low-level RTT operations—like creating render targets, scenes, and cameras—within a single function call. This unlocks advanced effects like post-processing, feedback loops, and real-time procedural texture generation within the declarative TSL workflow.
Common Uses
Generating real-time procedural textures, e.g., 'baking' a complex noise calculation into a map.
Chaining post-processing effects by using the output of one filter as the input for the next.
Creating feedback loops and simulations by reading the previous frame's result to create trails or reaction-diffusion effects.
Serving as a performance cache by rendering a static but computationally expensive node graph once and reusing its result.
How to adjust
Adjust by providing a configuration object as the second argument, e.g., `{ width: 512, height: 512 }` controls the generated texture's resolution, which is a trade-off between performance and quality. Fundamentally changing its first argument (the input node network) alters the content being 'snapshotted', such as introducing a `timerLocal` node to create a dynamically changing texture.
Code Examples
1// 1. Create a dynamic pattern that changes over time
2const animatedPattern = checkerPattern.uv( uv().add( sin( timerLocal() ) ) );
3
4// 2. "Snapshot" this animated pattern into a texture that updates automatically each frame
5const dynamicTexture = convertToTexture( animatedPattern );