directionToColor
Remaps a direction vector (like a normal) from the [-1, 1] range to the [0, 1] color range, primarily for data visualization and debugging.
Core Advantages
Provides strong semantic clarity by wrapping a common mathematical transform into a standard function, greatly simplifying the process of debugging by visualizing direction vectors like normals and light direction.
Common Uses
Visualizing model normals for debugging
Visualizing view direction to create MatCap or Fresnel effects
Visualizing light direction to validate lighting calculations
Creating procedural textures based on position or other vectors
How to adjust
This node is adjusted by changing its input vector. For example, inputting `normalWorld` produces fixed, world-oriented colors, while inputting `normalView` produces colors that change as the camera rotates, which is useful for creating MatCap effects.
Code Examples
1// Convert the world normal vector to a color for visual debugging
2material.colorNode = directionToColor( normalWorld );