scriptable
Allows wrapping a `code` node containing a custom GLSL function and mapping its input parameters to other TSL nodes, enabling seamless use of custom logic within the node graph.
Core Advantages
Its core value is providing ultimate flexibility and seamless interoperability. It lets you integrate any complex GLSL algorithm (like custom noise or external code snippets) into the TSL workflow as if it were a standard node, achieving unique effects not possible with built-in nodes.
Common Uses
Implementing custom procedural noise or patterns (e.g., Worley noise)
Integrating and adapting external GLSL code snippets (e.g., effects from ShaderToy)
Writing complex geometry deformation logic in the vertex shader
How to adjust
Adjusted by changing the TSL nodes passed into the `parameters` object. For example, in the code above, increasing the value of the `freq` uniform from `10.0` to `50.0` will increase the frequency of the `sin` function, making the stripe pattern on the model's surface visually denser.
Code Examples
1// 1. Define a GLSL function in a code node
2const customFunc = code(`
3 vec3 myPattern(vec2 coords, float freq) {
4 return vec3(sin(coords.x * freq), coords.y, 0.0);
5 }
6`);
7
8// 2. Use scriptable to call it, mapping TSL nodes to its parameters
9const result = scriptable(
10 customFunc,
11 { coords: uv(), freq: uniform(10.0) }
12);