Math Distance calculates the spatial separation or relationship between two vectors. While the standard "Distance" node only offers Euclidean length, this utility provides a comprehensive set of 5 distinct metrics: Euclidean, Manhattan, Chebyshev, Minkowski, and Cosine. These different modes allow you to shape distance fields into spheres, diamonds, cubes, or angular gradients, making it a fundamental building block for procedural shaping, proximity effects, and pattern generation.
Usage & Behavior
Vector Logic: Practical Applications
The power of this node comes from what vectors you compare. Here are three standard workflows:
Input 1: Surface Normal (N)
Input 2: Vector (0, 0, 1) [Up]
By calculating the Cosine Distance between the surface Normal and the "Up" vector, you isolate surfaces facing the sky. Use this to mask snow, dust, or rain wetness on top of objects.
Input 1: Shading Point (P)
Input 2: Object Location
Calculates the physical distance from the shading point to a specific object (like an Empty). Use the result to drive a glow that gets brighter as an object gets closer, or to create a spherical mask in 3D space.
Input 1: UV Coordinate
Input 2: Center (0.5, 0.5, 0)
By measuring the distance from the center of a UV tile, you create geometric gradients. Chebyshev creates a square box gradient (perfect for paneling), while Manhattan creates a diamond gradient (sci-fi shields).
The visual output of this node changes drastically depending on the Mode. If you calculate the distance from the center (0,0,0) to the current shading point (P), Euclidean creates a smooth radial gradient (like a ball), while Manhattan creates a pyramid/diamond shape, and Chebyshev creates a box. Cosine is unique—it doesn't measure length, but direction.
Key Features
- 5 Geometric Norms: Covers L1, L2, L-Infinity, and Angular metrics.
- Optimized Math: Calculates complex relationships in a single atomic operation.
- Shape Control: Turns simple distance gradients into geometric primitives.
Deep Dive: Metric Geometry
How you measure "distance" defines the shape of the world.
The ruler distance. "As the crow flies."
Shape: Sphere / Circle.
Taxicab geometry. $|x| + |y| + |z|$.
Shape: Diamond / Octahedron.
Chessboard distance. $max(|x|, |y|, |z|)$.
Shape: Cube / Square.
Angular difference. Ignored length.
Shape: Conical Gradient.
Parameters
- EUCLIDEAN: Standard physical distance. $ \sqrt{x^2 + y^2 + z^2} $.
- MANHATTAN: Sum of absolute differences. Useful for "tech" patterns or circuit logic.
- CHEBYSHEV: Maximum axis difference. Creates square/box falloffs.
- MINKOWSKI: Generalized $L^p$ distance.
- COSINE: Returns the cosine of the angle between the two vectors (1.0 = Same direction, 0.0 = 90 deg, -1.0 = Opposite).
Quick Recipes
Practical uses for different metrics.
Box Mask
- Mode CHEBYSHEV
- Input 1 Object Coords
- Input 2 (0,0,0)
Facing Ratio
- Mode COSINE
- Input 1 Normal (N)
- Input 2 (0,0,1) [Up]
Tech Forcefield
- Mode MANHATTAN
- Input 1 Object Coords
- Math Fraction
