radians
A function node that converts the developer-intuitive 'degree' unit into the 'radian' unit required by trigonometric functions in shaders.
Core Advantages
Significantly improves code readability and developer intuition. It allows developers to think and code using familiar angle units (e.g., 90, 180) while ensuring a seamless and performant mapping to the underlying GLSL/WGSL `radians()` function.
Common Uses
Intuitively controlling model rotations using degree-based uniform variables.
Converting angle parameters into the required radian inputs for `sin/cos` when procedurally generating patterns like spirals or radial gradients.
Implementing spotlight effects by converting cone angles, typically set in degrees, into radians for lighting calculations.
Serving as the inverse operation to the `degrees()` node, fundamental to TSL's unit conversion system.
How to adjust
Adjusting the node's input value (in degrees) linearly changes its output radian value, thus intuitively affecting the final visual result. For example, changing the input from a static value like `radians(90)` to a time-based one like `radians(timerLocal().mul(60))` will turn a static rotation into a continuous animation at 60 degrees per second. Similarly, controlling the input angle with a uniform allows for dynamic adjustment of procedural texture frequency or density.
Code Examples
1// Assuming angleInDegrees is a node with a value in degrees, e.g., uniform(90)
2const angleInRadians = radians( angleInDegrees );
3
4// angleInRadians can now be safely used by functions like sin, cos, etc.
5const result = sin( angleInRadians );