colorToDirection
Remaps a color or data value from the [0, 1] range (e.g., sampled from a texture) to the [-1, 1] range, commonly used to unpack color information into a direction vector.
Core Advantages
Encapsulates a standard data unpacking operation (`val * 2.0 - 1.0`) into a single, highly semantic function. It simplifies the node graph, improves readability, and prevents potential errors from manually chaining multiple math nodes.
Common Uses
Decoding Normal Maps for lighting calculations
Processing Flow Maps to generate animation vectors
Converting standard noise ([0, 1]) into bipolar noise ([-1, 1])
How to adjust
This node is a fixed mathematical transform with no adjustable parameters. Its effect is demonstrated by correct data handling: for instance, using raw color values from a normal map for lighting results in completely wrong visuals. After processing with this node, the normal information is correctly restored, allowing a flat surface to display realistic bumps, details, and lighting responses.
Code Examples
1// Unpack color sampled from a normal map into a usable normal vector
2const normalVector = colorToDirection( normalMapTexture.xyz );