difference
difference
Calculates the absolute difference between two values, representing their non-directional discrepancy.
Core Advantages
Its core value is semantic clarity. `difference(a, b)` more intuitively expresses the intent of 'calculating a difference' than `abs(sub(a, b))`, simplifying the node graph and improving code readability.
Common Uses
Procedural pattern generation (e.g., stripes, grids)
Edge detection (e.g., toon outlines)
Creating color or brightness masks
Implementing symmetry and mirroring effects
How to adjust
By making one of its inputs dynamic (e.g., connecting a `time` node), you can create moving effects like a line scanning across the screen. Using two textures as inputs can achieve edge detection or image comparison effects.
Code Examples
1// Create a V-shaped gradient centered on the screen
2const vShape = difference( uv.x, 0.5 );